<template>
    <div
        class="filter"
        style="position: relative"
    >
        <div class="filter-item">
            <label for="">所属单位：</label>
            <el-select
                v-model="searchForm.depId"
                class="m-2"
                style="width: 125px"
                :disabled="localTypeUnit != '1'"
            >
                <el-option
                    v-for="item in depIdList"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                />
            </el-select>
        </div>

        <div class="filter-item">
            <label for="">值班日期：</label>
            <el-date-picker
                style="width: 140px"
                v-model="searchForm.taskDate"
                format="YYYY-MM-DD"
                type="date"
                :size="'default'"
                :shortcuts="shortcuts"
                @change="taskDateChange"
            />
        </div>
        <div class="filter-item">
            <label for="">值班人数：</label>
            <el-input
                v-model="searchForm.onDutyCount"
                style="width: 125px"
                disabled
            />
        </div>
        <div class="filter-item">
            <label for="">值班人员：</label>
            <el-input
                v-model="searchForm.onDutyName"
                style="width: 180px"
                disabled
            />
        </div>
        <div
            class="filter-item"
            v-if="tableActiveName == 'drawing'"
        >
            <el-button
                size="default"
                type="primary"
                @click="drawingHandleClick('add')"
            >新增曲线</el-button>
            <!-- :disabled="hasMember" -->
        </div>
        <div
            class="filter-item"
            v-if="tableActiveName != 'drawing'"
        >
            <el-button
                size="default"
                type="primary"
                @click="chooceTodayTask"
            >选择今日任务</el-button>
            <!-- :disabled="hasMember" -->
        </div>
        <div class="filter-item">
            <el-button
                size="default"
                type="primary"
                @click="saveTemplate"
            >存为模板</el-button>
        </div>
        <div
            class="tips"
            @click="tipsDialog"
            v-show="tableActiveName == 'process'"
        >
            <el-icon size="14">
                <Opportunity />
            </el-icon>
            <span>总体原则: 上午必须完成COD、氮磷的消解进样</span>

            <el-icon size="14">
                <ArrowDownBold />
            </el-icon>
        </div>
        <div
            class="process"
            v-show="taskCategoryType == 1"
        >实时进度： {{process }}</div>
    </div>
    <el-tabs
        v-model="tableActiveName"
        class="demo-tabs"
    >
        <el-tab-pane
            :label="taskCategoryType == 1 ? '流程' : '自定义流程'"
            name="process"
        >
            <el-table
                :data="myTask"
                style="width: 100%"
                id="inspectionTask"
                v-if="myTask.length > 0 && taskCategoryType == 1"
            >
                <el-table-column
                    prop="time"
                    label="推荐时间"
                    width="100"
                >
                    <template #default="scope">
                        <span
                            :class="timeTipClass(scope.row, scope.$index)"
                            v-if="scope.row.planStartTime"
                        >{{scope.row.planStartTime}}-{{scope.row.planEndTime}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="title"
                    label="任务项"
                    width="120"
                />
                <el-table-column
                    prop="stepTitle"
                    label="操作步骤"
                    width="150"
                >
                    <template #default="scope">
                        <span>{{scope.row.isNess == 0 ? '[可选]' : ''}}{{scope.row.stepTitle}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="decomposeStepTitle"
                    label="步骤分解"
                    width="150"
                />
                <el-table-column
                    prop="finishCheck"
                    label=""
                    width="46"
                >
                    <template #default="scope">
                        <el-checkbox
                            v-model="scope.row.processResultChecked"
                            @change="(val) => finishCheckChange(val, scope.row)"
                        />
                    </template>
                </el-table-column>
                <el-table-column
                    prop="content"
                    label="具体内容"
                >
                    <template #default="scope">
                        <div style="display: flex;flex-direction: row;align-items: center;">
                            <el-tooltip
                                class="box-item"
                                effect="dark"
                                placement="top"
                            >
                                <template #content>
                                    <div style="max-width: 500px;">{{scope.row.content}}</div>
                                </template>
                                <div class="contentStyle">{{ scope.row.content }}</div>
                            </el-tooltip>
                            <el-tooltip
                                class="box-item"
                                effect="light"
                                placement="top"
                                v-if="scope.row.considerations"
                            >
                                <template #content>
                                    <div style="max-width: 500px;">{{scope.row.considerations}}</div>
                                </template>
                                <el-icon
                                    color="#58be3f"
                                    size="18"
                                    style="margin-left: 5px;"
                                >
                                    <QuestionFilled />
                                </el-icon>
                            </el-tooltip>
                            <el-tooltip
                                class="box-item"
                                effect="light"
                                placement="top"
                                v-if="scope.row.considerationsFileId"
                                @show="
                                    getFileInfoById(scope.row.considerationsFileId)
                                "
                            >
                                <template #content>
                                    <el-image
                                        v-if="scope.row.considerationsFileId"
                                        :src="considerationsFileUrl ? considerationsFileUrl : ''"
                                        alt=""
                                        style="width: 600px"
                                    />
                                </template>
                                <el-icon
                                    color="#58be3f"
                                    size="18"
                                    style="margin-left: 5px;"
                                >
                                    <Picture />
                                </el-icon>
                            </el-tooltip>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="checkResult"
                    label="检测结果"
                    width="176px"
                >
                    <template #default="scope">
                        <div class="loactionResult">
                            <div
                                class="loactionResultEdit"
                                v-if="moment().format('YYYY-MM-DD') == moment(searchForm.taskDate).format('YYYY-MM-DD')"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="填报"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="Edit"
                                        @click="handleClick('report', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div
                                class="loactionResultEdit"
                                v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="补录"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="EditPen"
                                        @click="handleClick('update', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div
                                class="loactionResultEdit"
                                v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="修正"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="Edit"
                                        @click="handleClick('edit', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div class="loactionResultEdit">
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="修正记录"
                                    placement="top-start"
                                    v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="List"
                                        @click="handleClick('editList', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div
                                class="loactionResultEdit"
                                v-if="(scope.row.id == 3280 || scope.row.id == 3283 || scope.row.id == 3286) && scope.row.stepTitle == '曲线的绘制'"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="曲线绘制"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="warning"
                                        size="small"
                                        :icon="Histogram"
                                        @click="handleDrawingClick(scope.row, 'process', scope.row.id)"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <el-table
                :data="myPersonalTask"
                style="width: 100%"
                id="inspectionTask"
                v-if="myPersonalTask.length > 0 && taskCategoryType == 2"
            >
                <el-table-column
                    prop="finishTime"
                    label="完成时间"
                    width="100"
                >
                    <template #default="scope">
                        {{ scope.row.finishTime }}
                    </template>
                </el-table-column>
                <el-table-column
                    prop="title"
                    label="任务项"
                    width="100"
                />
                <el-table-column
                    prop="stepTitle"
                    label="操作步骤"
                    width="150"
                />
                <el-table-column
                    prop="decomposeStepTitle"
                    label="步骤分解"
                    width="150"
                />
                <el-table-column
                    prop="finishCheck"
                    label=""
                    width="46"
                >
                    <template #default="scope">
                        <el-checkbox
                            v-model="scope.row.processResultChecked"
                            @change="(val) => finishCheckChange(val, scope.row)"
                        />
                    </template>
                </el-table-column>
                <el-table-column
                    prop="content"
                    label="具体内容"
                >
                    <template #default="scope">
                        <div style="display: flex;flex-direction: row;align-items: center;">
                            <el-tooltip
                                class="box-item"
                                effect="dark"
                                placement="top"
                            >
                                <template #content>
                                    <div style="max-width: 500px;">{{scope.row.content}}</div>
                                </template>
                                <div class="contentStyle">{{ scope.row.content }}</div>
                            </el-tooltip>
                            <el-tooltip
                                class="box-item"
                                effect="light"
                                placement="top"
                                v-if="scope.row.considerations"
                            >
                                <template #content>
                                    <div style="max-width: 500px;">{{scope.row.considerations}}</div>
                                </template>
                                <el-icon
                                    color="#58be3f"
                                    size="18"
                                    style="margin-left: 5px;"
                                >
                                    <QuestionFilled />
                                </el-icon>
                            </el-tooltip>
                        </div>
                    </template>
                </el-table-column>
                <el-table-column
                    prop="checkResult"
                    label="检测结果"
                    width="176px"
                >
                    <template #default="scope">
                        <div class="loactionResult">
                            <div
                                class="loactionResultEdit"
                                v-if="moment().format('YYYY-MM-DD') == moment(searchForm.taskDate).format('YYYY-MM-DD')"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="填报"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="Edit"
                                        @click="handleClick('report', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div
                                class="loactionResultEdit"
                                v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="补录"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="EditPen"
                                        @click="handleClick('update', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div
                                class="loactionResultEdit"
                                v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="修正"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="Refresh"
                                        @click="handleClick('edit', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div
                                class="loactionResultEdit"
                                v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="修正记录"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="primary"
                                        size="small"
                                        :icon="List"
                                        @click="handleClick('editList', scope.row)"
                                        :disabled="scope.row.taskCategory == 1"
                                        style="margin-right: 4px;"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                            <div
                                class="loactionResultEdit"
                                v-if="(scope.row.id == 3280 || scope.row.id == 3283 || scope.row.id == 3286) && scope.row.stepTitle == '曲线的绘制'"
                            >
                                <el-tooltip
                                    class="box-item"
                                    effect="dark"
                                    content="曲线绘制"
                                    placement="top-start"
                                >
                                    <el-button
                                        type="warning"
                                        size="small"
                                        :icon="Histogram"
                                        @click="handleDrawingClick(scope.row, 'process', scope.row.id)"
                                    >
                                    </el-button>
                                </el-tooltip>
                            </div>
                        </div>
                    </template>
                </el-table-column>
            </el-table>
            <el-empty
                v-if="myPersonalTask.length == 0 && taskCategoryType == 2"
                description="自定义模式无推荐流程，请在[任务]填报"
            />
            <el-empty
                v-if="myTask.length == 0 && taskCategoryType == 1"
                description="暂无任务"
            />
        </el-tab-pane>
        <el-tab-pane
            label="我的任务"
            name="my"
        >
            <el-tabs
                v-model="taskVoListActiveName"
                class="demo-tabs"
            >
                <el-tab-pane
                    v-for="(item, index) in myTaskObj.taskVoList"
                    :key="item.id"
                    :label="item.title"
                    :name="index"
                >
                    <template #label>
                        <span style="margin-right: 10px;">{{item.title}}</span>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="填报"
                            placement="top-start"
                            v-if="moment().format('YYYY-MM-DD') == moment(searchForm.taskDate).format('YYYY-MM-DD')"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('report', item)"
                            >
                                <Edit />
                            </el-icon>
                        </el-tooltip>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="补录"
                            placement="top-start"
                            v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('update', item)"
                            >
                                <EditPen />
                            </el-icon>
                        </el-tooltip>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="修正"
                            placement="top-start"
                            v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('edit', item)"
                            >
                                <Refresh />
                            </el-icon>
                        </el-tooltip>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="修正记录"
                            placement="top-start"
                            v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('editList', item)"
                            >
                                <List />
                            </el-icon>
                        </el-tooltip>
                    </template>
                    <div
                        class="demo-collapse"
                        style="padding: 0 20px;"
                    >
                        <el-collapse
                            v-for="(m, n) in item.childrens"
                            :key="n"
                            v-model="childrensActiveNames"
                        >
                            <el-collapse-item :name="n">
                                <template #title>
                                    <!-- <el-checkbox v-model="m.processResultCheckedprocessResultChecked" /> -->

                                    <!-- <el-checkbox-group
                                        v-model="checkedAll"
                                        @change="handleCheckedCitiesChange"
                                    >
                                    </el-checkbox-group> -->
                                    <span style="color: #58be3f; margin-right: 10px;">{{m.isNess == 0 ? '[可选]' : ''}}{{m.title}}</span>
                                    <el-icon
                                        v-if="(item.id == 3280 || item.id == 3283 || item.id == 3286) && m.title == '曲线的绘制'"
                                        :size="16"
                                        color="#58be3f"
                                        @click.stop="handleDrawingClick(m, 'my', item.id)"
                                    >
                                        <Histogram />
                                    </el-icon>
                                </template>
                                <div
                                    v-for="(k, p) in m.childrens"
                                    :key="p"
                                >
                                    <div class="demo-collapse-childrens_title">
                                        <el-checkbox
                                            v-model="k.processResultChecked"
                                            @change="(val) => finishCheckChange(val, k)"
                                        />
                                        <span style="margin-left: 6px;color: #666;">{{ k.title }}</span>
                                        <el-tooltip
                                            class="box-item"
                                            effect="light"
                                            placement="top"
                                            v-if="k.considerationsFileId"
                                            @show="
                                                getFileInfoById(k.considerationsFileId)
                                            "
                                        >
                                            <template #content>
                                                <el-image
                                                    v-if="k.considerationsFileId"
                                                    :src="considerationsFileUrl ? considerationsFileUrl : ''"
                                                    alt=""
                                                    style="width: 600px"
                                                />
                                            </template>
                                            <el-icon
                                                color="#58be3f"
                                                size="18"
                                                style="margin-left: 5px;"
                                            >
                                                <Picture />
                                            </el-icon>
                                        </el-tooltip>
                                    </div>
                                    <div style="margin-left: 20px;color: #999;">{{ k.description }}</div>
                                </div>
                            </el-collapse-item>
                        </el-collapse>
                    </div>
                </el-tab-pane>
            </el-tabs>
        </el-tab-pane>
        <!-- <el-tab-pane
            label="全部任务"
            name="all"
        >
            <el-tabs
                v-model="taskVoListActiveName"
                class="demo-tabs"
            >
                <el-tab-pane
                    v-for="(item, index) in allTask.taskVoList"
                    :key="item.id"
                    :label="item.title"
                    :name="index"
                >
                    <template #label>
                        <span style="margin-right: 10px;">{{item.title}}</span>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="填报"
                            placement="top-start"
                            v-if="moment().format('YYYY-MM-DD') == moment(searchForm.taskDate).format('YYYY-MM-DD')"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('report', item)"
                            >
                                <Edit />
                            </el-icon>
                        </el-tooltip>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="补录"
                            placement="top-start"
                            v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('update', item)"
                            >
                                <EditPen />
                            </el-icon>
                        </el-tooltip>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="修正"
                            placement="top-start"
                            v-if="moment().format('YYYY-MM-DD') != moment(searchForm.taskDate).format('YYYY-MM-DD')"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('edit', item)"
                            >
                                <Refresh />
                            </el-icon>
                        </el-tooltip>
                        <el-tooltip
                            class="box-item"
                            effect="dark"
                            content="修正记录"
                            placement="top-start"
                        >
                            <el-icon
                                :size="16"
                                color="#58be3f"
                                v-if="item.taskCategory == 2 || item.taskCategory == 3"
                                @click="handleClick('editList', item)"
                            >
                                <List />
                            </el-icon>
                        </el-tooltip>
                    </template>
                    <div
                        class="demo-collapse"
                        style="padding: 0 20px;"
                    >
                        <el-collapse
                            v-for="(m, n) in item.childrens"
                            :key="n"
                            v-model="childrensActiveNames"
                        >
                            <el-collapse-item :name="n">
                                <template #title>
                                    <span style="color: #58be3f; margin-right: 10px;">{{m.isNess == 0 ? '[可选]' : ''}}{{m.title}}</span>
                                    <el-icon
                                        v-if="(item.id == 3280 || item.id == 3283 || item.id == 3286) && m.title == '曲线的绘制'"
                                        :size="16"
                                        color="#58be3f"
                                        @click.stop="handleDrawingClick(m, 'my', item.id)"
                                    >
                                        <Histogram />
                                    </el-icon>
                                </template>
                                <div
                                    v-for="(k, p) in m.childrens"
                                    :key="p"
                                >
                                    <div class="demo-collapse-childrens_title">
                                        <el-checkbox
                                            v-model="k.processResultChecked"
                                            @change="(val) => finishCheckChange(val, k)"
                                        /> <span style="margin-left: 6px;color: #666;">{{ k.title }}</span>
                                    </div>
                                    <div style="margin-left: 20px;color: #999;">{{ k.description }}</div>
                                </div>
                            </el-collapse-item>
                        </el-collapse>
                    </div>
                </el-tab-pane>
            </el-tabs>
        </el-tab-pane> -->
        <el-tab-pane
            label="曲线绘制"
            name="drawing"
        >
            <div class="filter">
                <div class="filter-item">
                    <label for="">曲线编号：</label>
                    <el-input
                        v-model="linearSearchForm.lineName"
                        style="width: 125px"
                    />
                </div>
                <div class="filter-item">
                    <label for="">绘制日期：</label>
                    <el-date-picker
                        style="width: 220px"
                        v-model="linearSearchForm.dateTime"
                        type="daterange"
                        unlink-panels
                        range-separator="至"
                        start-placeholder="开始时间"
                        end-placeholder="结束时间"
                        :size="'default'"
                    />
                </div>
                <div class="filter-item">
                    <label for="">曲线类型：</label>
                    <el-select
                        v-model="linearSearchForm.lineCategory"
                        class="m-2"
                        style="width: 145px"
                    >
                        <el-option
                            v-for="item in lineCategoryList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="filter-item">
                    <label for="">回测验证：</label>
                    <el-select
                        v-model="linearSearchForm.isQualified"
                        class="m-2"
                        style="width: 145px"
                    >
                        <el-option
                            v-for="item in isQualifiedList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
                <div class="filter-item">
                    <el-button
                        size="default"
                        type="primary"
                        @click="searchDrawingList"
                    >查询</el-button>
                    <el-button
                        size="default"
                        @click="reset"
                    >重置</el-button>
                </div>
            </div>
            <el-table
                :data="drawingList"
                style="width: 100%"
                id="inspectionTask"
            >
                <el-table-column
                    type="index"
                    label="序号"
                    width="55"
                />
                <el-table-column
                    prop="title"
                    label="所属单位"
                    width="100"
                >
                    <template #default="scope">
                        {{ depNameTranslate(scope.row.depId) }}
                    </template>
                </el-table-column>
                <el-table-column
                    prop="createTime"
                    label="绘制日期"
                    width="100"
                >
                    <template #default="scope">{{ moment(scope.row.createTime).format('YYYY-MM-DD') }}</template>
                </el-table-column>
                <el-table-column
                    prop="lineCategory"
                    label="曲线类型"
                >
                    <template #default="scope">
                        {{ scope.row.lineCategory == 1 ? 'NH₃-N曲线' : scope.row.lineCategory == 2 ? 'TN曲线' : 'TP曲线' }}
                    </template>
                </el-table-column>
                <el-table-column
                    prop="lineName"
                    label="曲线编号"
                    width="200"
                />
                <el-table-column
                    prop="expression"
                    label="曲线方程"
                    width="300"
                />
                <el-table-column
                    prop="isQualified"
                    label="回测验证"
                >
                    <template #default="scope">
                        {{ scope.row.isQualified == 1 ? '合格' : scope.row.isQualified == 2 ? '不合格' : ' ' }}
                    </template>
                </el-table-column>
                <el-table-column
                    fixed="right"
                    label="操作"
                    width="160"
                >
                    <template #default="scope">
                        <el-button
                            type="primary"
                            size="small"
                            :icon="View"
                            @click="curveHandleClick('detail', scope.row)"
                        >
                        </el-button>
                        <el-button
                            type="primary"
                            size="small"
                            :icon="Edit"
                            @click="curveHandleClick('edit', scope.row)"
                        >
                        </el-button>
                        <el-button
                            type="danger"
                            size="small"
                            :icon="Delete"
                            @click="delCurveHandleClick(scope.row)"
                        ></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                v-model:current-page="linearSearchForm.pageNo"
                v-model:page-size="linearSearchForm.pageSize"
                layout="total, prev, pager, next, jumper"
                :total="drawingListTotal"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                class="paginationStyle"
            />
        </el-tab-pane>
    </el-tabs>
    <el-dialog
        v-model="chooceTaskVisiable"
        v-if="chooceTaskVisiable"
        title="选择今日任务"
        width="900"
    >
        <div style="padding: 0 10px;">
            <div class="taskInfo">
                <p>值班日期： {{ moment(searchForm.taskDate).format('YYYY-MM-DD')}}</p>
                <p>值班人数： {{ searchForm.onDutyCount }}</p>
                <p>值班人员： {{ searchForm.onDutyName }}</p>
            </div>

            <el-tabs
                v-model="dialogActiveType"
                class="demo-tabs"
            >
                <el-tab-pane
                    label="平台模板"
                    name="1"
                    key="1"
                >
                    <el-tabs
                        v-model="dialogActiveName"
                        class="demo-tabs"
                    >
                        <el-tab-pane
                            :label="item.templateName"
                            :name="index"
                            v-for="(item, index) in templateList.list"
                            :key="index"
                        >
                            <div class="templateInfo">
                                <div
                                    class="templateInfoItem"
                                    v-for="m in item.personnelNum"
                                    :key="m"
                                >
                                    <div class="templateInfoItemHeader">
                                        <div class="itemTitle">任务项</div>
                                        <div class="itemChecked">
                                            <el-checkbox
                                                v-if="m == 1"
                                                v-model="item.templatechecked1"
                                                :indeterminate="item.isIndeterminate1"
                                                @change="(val) => templatechecked(val, index, m)"
                                            />
                                            <el-checkbox
                                                v-if="m == 2"
                                                v-model="item.templatechecked2"
                                                :indeterminate="item.isIndeterminate2"
                                                @change="(val) => templatechecked(val, index, m)"
                                            />
                                            <el-checkbox
                                                v-if="m == 3"
                                                v-model="item.templatechecked3"
                                                :indeterminate="item.isIndeterminate3"
                                                @change="(val) => templatechecked(val, index, m)"
                                            />
                                        </div>
                                    </div>
                                    <div
                                        class="templateInfoItemContent"
                                        v-if="m == 1"
                                    >
                                        <el-scrollbar height="260">
                                            <p
                                                v-for="p in item.requiredTitlesItemsList"
                                                :key="p"
                                            >

                                                <el-checkbox
                                                    v-model="p.checked"
                                                    @change="(val) => templatecheckedChild(val, index, m)"
                                                />
                                                <span>{{ p.itemValue }}</span>
                                            </p>
                                        </el-scrollbar>
                                    </div>
                                    <div
                                        class="templateInfoItemContent"
                                        v-if="m == 2"
                                    >
                                        <el-scrollbar height="260">
                                            <p
                                                v-for="p in item.requiredTitlesItems2List"
                                                :key="p"
                                            >

                                                <el-checkbox
                                                    v-model="p.checked"
                                                    @change="(val) => templatecheckedChild(val, index, m)"
                                                />
                                                <span>{{ p.itemValue }}</span>
                                            </p>
                                        </el-scrollbar>
                                    </div>
                                    <div
                                        class="templateInfoItemContent"
                                        v-if="m == 3"
                                    >
                                        <el-scrollbar height="260">
                                            <p
                                                v-for="p in item.requiredTitlesItems3List"
                                                :key="p"
                                            >

                                                <el-checkbox
                                                    v-model="p.checked"
                                                    @change="(val) => templatecheckedChild(val, index, m)"
                                                />
                                                <span>{{ p.itemValue }}</span>
                                            </p>
                                        </el-scrollbar>
                                    </div>
                                </div>
                            </div>
                        </el-tab-pane>
                    </el-tabs>
                </el-tab-pane>
                <el-tab-pane
                    label="个人模板"
                    name="2"
                    key="2"
                >
                    <el-tabs
                        v-model="dialogActivePersonalTemplateType"
                        class="demo-tabs"
                    >
                        <el-tab-pane
                            label="本人"
                            name="1"
                            key="1"
                        >
                            <el-table
                                :data="templateListPreson"
                                style="width: 100%"
                                height="300px"
                                id="inspectionTask"
                                v-if="templateListPreson.length > 0"
                            >
                                <el-table-column
                                    prop="templateName"
                                    label="模板名称"
                                />
                                <el-table-column
                                    prop="commets"
                                    label="描述"
                                />
                                <el-table-column
                                    prop="checkResult"
                                    label="选择"
                                    width="100"
                                >
                                    <template #default="scope">
                                        <el-checkbox
                                            v-model="scope.row.templatechecked"
                                            @change="(val) => personalTemplatecheckedPreson(val, scope.row, scope.$index)"
                                        />
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-empty
                                v-else
                                description="暂无数据"
                            />
                        </el-tab-pane>
                        <el-tab-pane
                            label="全部"
                            name="2"
                            key="2"
                        >
                            <el-table
                                :data="templateListAll"
                                style="width: 100%"
                                height="300px"
                                id="inspectionTask"
                                v-if="templateListAll.length > 0"
                            >
                                <el-table-column
                                    prop="templateName"
                                    label="模板名称"
                                />
                                <el-table-column
                                    prop="commets"
                                    label="描述"
                                />
                                <el-table-column
                                    prop="checkResult"
                                    label="选择"
                                    width="100"
                                >
                                    <template #default="scope">
                                        <el-checkbox
                                            v-model="scope.row.templatechecked"
                                            @change="(val) => personalTemplatecheckedAll(val, scope.row, scope.$index)"
                                        />
                                    </template>
                                </el-table-column>
                            </el-table>
                            <el-empty
                                v-else
                                description="暂无数据"
                            />
                        </el-tab-pane>
                    </el-tabs>
                </el-tab-pane>
                <el-tab-pane
                    label="自定义"
                    name="3"
                    key="3"
                >
                    <div class="templateInfo">
                        <div class="templateInfoItem all">

                            <el-checkbox
                                v-model="checkAll"
                                :indeterminate="isIndeterminateAll"
                                @change="handleCheckAllChangeAll"
                                class="allChecked"
                            >
                                全部
                            </el-checkbox>
                            <div class="tempTypeTitle">
                                <span style="margin-right: 20px">操作规范</span>
                                <el-checkbox
                                    v-model="checkType1"
                                    :indeterminate="isIndeterminateType1"
                                    @change="(v) => handleCheckAllChangeType(v, '1')"
                                >
                                    全选
                                </el-checkbox>
                            </div>
                            <br />
                            <p
                                v-for="item in taskList"
                                :key="item.id"
                                v-show="item.taskCategory == 1"
                            >
                                <el-checkbox-group
                                    v-model="checkList"
                                    @change="handleCheckedChange"
                                >
                                    <el-checkbox :value="item.id">{{ item.title }}</el-checkbox>
                                </el-checkbox-group>
                            </p>
                            <div class="tempTypeTitle">
                                <span style="margin-right: 20px">水质数据</span>
                                <el-checkbox
                                    v-model="checkType2"
                                    :indeterminate="isIndeterminateType2"
                                    @change="(v) => handleCheckAllChangeType(v, '2')"
                                >
                                    全选
                                </el-checkbox>
                            </div>
                            <br />
                            <p
                                v-for="
                                item
                                in
                                taskList"
                                :key="item.id"
                                v-show="item.taskCategory == 2"
                            >
                                <el-checkbox-group
                                    v-model="checkList"
                                    @change="handleCheckedChange"
                                >
                                    <el-checkbox :value="item.id">{{ item.title }}</el-checkbox>
                                </el-checkbox-group>
                            </p>
                            <div class="tempTypeTitle">
                                <span style="margin-right: 20px">工艺数据</span>
                                <el-checkbox
                                    v-model="checkType3"
                                    :indeterminate="isIndeterminateType3"
                                    @change="(v) => handleCheckAllChangeType(v, '3')"
                                >
                                    全选
                                </el-checkbox>
                            </div>
                            <br />
                            <p
                                v-for="item in taskList"
                                :key="item.id"
                                v-show="item.taskCategory == 3"
                            >
                                <el-checkbox-group
                                    v-model="checkList"
                                    @change="handleCheckedChange"
                                >
                                    <el-checkbox :value="item.id">{{ item.title }}</el-checkbox>
                                </el-checkbox-group>
                            </p>
                        </div>
                    </div>
                </el-tab-pane>
            </el-tabs>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="chooceTaskVisiable = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="chooceTaskConfirm()"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>

    <el-dialog
        v-model="configVisible"
        :title="configTitle"
        style="min-width: 1092px"
        width="1092"
        :fullscreen="fullScreen"
        :show-close="false"
    >
        <template #header="{ titleClass }">
            <div class="my-header">
                <h4 :class="titleClass">{{configTitle}}</h4>
                <div class="rightBtn">
                    <el-icon
                        class="el-icon--left"
                        @click="fullscreenFn"
                        size="18"
                        color="#fff"
                        v-if="!fullScreen"
                        style=" margin-right: 12px;"
                    >
                        <FullScreen />
                    </el-icon>

                    <img
                        v-else
                        src="@/assets/images/closefull3.png"
                        alt=""
                        @click="fullscreenFn"
                        style=" width: 24px;height: 24px; margin-right: 12px;"
                    >
                    <el-icon
                        class="el-icon--left"
                        @click="configVisible = false,fullScreen = false"
                        size="20"
                        color="#fff"
                    >
                        <Close />
                    </el-icon>
                </div>
            </div>
        </template>
        <configNormal
            :taskSearchForm="searchForm"
            ref="configNormalRef"
            v-if="configVisible"
            @closed="configVisible = false"
        >
        </configNormal>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="configVisible = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="configNormalConfirm()"
                    v-loading="confirmLoading"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog
        v-model="configOtherVisible"
        :title="configOtherTitle"
        style="min-width: 1092px"
        :fullscreen="fullScreen"
        :show-close="false"
    >
        <template #header="{ titleClass }">
            <div class="my-header">
                <h4 :class="titleClass">{{configOtherTitle}}</h4>
                <div class="rightBtn">
                    <el-icon
                        class="el-icon--left"
                        @click="fullscreenFn"
                        size="18"
                        color="#fff"
                        v-if="!fullScreen"
                        style=" margin-right: 12px;"
                    >
                        <FullScreen />
                    </el-icon>

                    <img
                        v-else
                        src="@/assets/images/closefull3.png"
                        alt=""
                        @click="fullscreenFn"
                        style=" width: 24px;height: 24px; margin-right: 12px;"
                    >
                    <el-icon
                        class="el-icon--left"
                        @click="configOtherVisible = false,fullScreen = false"
                        size="20"
                        color="#fff"
                    >
                        <Close />
                    </el-icon>
                </div>
            </div>
        </template>
        <div v-if="configOtherVisible && handleClickTaskType == 3169">
            <el-tabs
                v-model="MLSS_MLVSS_NAME_INDEX"
                class="demo-tabs"
                @tab-change="relatedIndicatorchange"
            >
                <el-tab-pane
                    label="MLSS"
                    :name="0"
                >
                    <configOther3169_0
                        ref="configOther3169Ref_0"
                        :taskSearchForm="searchForm"
                        @closed="configOtherVisible = false"
                    ></configOther3169_0>
                </el-tab-pane>
                <el-tab-pane
                    label="MLVSS"
                    :name="1"
                >
                    <configOther3169_1
                        ref="configOther3169Ref_1"
                        :taskSearchForm="searchForm"
                        @closed="configOtherVisible = false"
                    ></configOther3169_1>
                </el-tab-pane>
            </el-tabs>
        </div>
        <configOther3298
            :taskSearchForm="searchForm"
            ref="configOther3298Ref"
            @closed="configVisible = false"
            v-if="configOtherVisible && handleClickTaskType == 3298"
        >
        </configOther3298>
        <configOther3289
            ref="configOther3289Ref"
            :taskSearchForm="searchForm"
            @closed="configOtherVisible = false"
            v-if="configOtherVisible && handleClickTaskType == 3289"
        ></configOther3289>
        <configOther1600
            ref="configOther1600Ref"
            :taskSearchForm="searchForm"
            @closed="configOtherVisible = false"
            v-if="configOtherVisible && handleClickTaskType == 1600"
        ></configOther1600>
        <configOther2922
            ref="configOther2922Ref"
            :taskSearchForm="searchForm"
            @closed="configOtherVisible = false"
            v-if="configOtherVisible && handleClickTaskType == 2922"
        ></configOther2922>
        <configOther3277
            ref="configOther3277Ref"
            :taskSearchForm="searchForm"
            @closed="configOtherVisible = false"
            v-if="configOtherVisible && handleClickTaskType == 3277"
        ></configOther3277>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="configOtherVisible = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="configOtherConfirm(handleClickTaskType)"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
    <!-- 曲线绘制类型 -->
    <el-dialog
        v-model="drawingTypeVisible"
        v-if="drawingTypeVisible"
        title="新增曲线"
        width="600"
    >
        <div
            class="dialogContent"
            style="margin-top: 20px;width: 568px;"
        >
            <el-form
                ref="templateFormRef"
                :model="drawingForm"
                label-width="100px"
                class="demo-ruleForm"
                :inline="true"
            >
                <div class="dialogModel">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item
                                label="曲线类型："
                                prop="lineCategory"
                                style="width: 100%;"
                            >
                                <el-select
                                    v-model="drawingForm.lineCategory"
                                    class="m-2"
                                >
                                    <el-option
                                        v-for="item in drawingTypeList"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
            </el-form>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="drawingTypeVisible = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="drawingTypeConfirm()"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
    <!-- 曲线绘制 -->
    <el-dialog
        v-model="drawingVisible"
        v-if="drawingVisible"
        :title="drawingTitle"
        width="992"
    >
        <TnLine
            ref="drawingLineRef"
            :handleType="handleType"
            :handleRowDetail="handleRowDetail"
            v-if="drawingType == '2' && drawingVisible"
            @linearEquationFn="linearEquationFn"
        ></TnLine>
        <TpLine
            ref="drawingLineRef"
            :handleType="handleType"
            :handleRowDetail="handleRowDetail"
            v-if="drawingType == '3' && drawingVisible"
            @linearEquationFn="linearEquationFn"
        ></TpLine>
        <Nh3Line
            ref="drawingLineRef"
            :handleType="handleType"
            :handleRowDetail="handleRowDetail"
            v-if="drawingType == '1' && drawingVisible"
            @linearEquationFn="linearEquationFn"
        ></Nh3Line>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="drawingVisible = false">取消</el-button>
                <el-button
                    v-if="handleType != 'detail'"
                    type="primary"
                    @click="drawingConfirm()"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog
        v-model="paintVisible"
        title="关联曲线"
        width="592"
    >
        <div
            class="dialogContent"
            style="margin-top: 20px;width: 568px;"
        >
            <el-form
                :model="paintForm"
                label-width="100px"
                class="demo-ruleForm"
                :inline="true"
            >
                <div class="dialogModel">
                    <el-row>
                        <el-col :span="16">
                            <el-form-item
                                label="曲线："
                                prop="lineCategory"
                                style="width: 100%;"
                            >
                                <el-select
                                    v-model="paintForm.lineId"
                                    class="m-2"
                                    style="width: 200px;margin-left: 20px;"
                                >
                                    <el-option
                                        v-for="p in linearEquationPaintList"
                                        :key="p.id"
                                        :label="p.lineName"
                                        :value="p.id"
                                    />
                                </el-select>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
            </el-form>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="paintVisible = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="paintConfirm()"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog
        v-model="saveTemplateVisible"
        title="存为模板"
        width="592"
    >
        <div
            class="dialogContent"
            style="margin-top: 20px;width: 568px;"
        >
            <el-form
                :model="saveTemplateForm"
                label-width="100px"
                class="demo-ruleForm"
                :inline="true"
            >
                <div class="dialogModel">
                    <el-row>
                        <el-col :span="16">
                            <el-form-item
                                label="模板名称"
                                prop="templateName"
                                style="width: 100%;"
                            >
                                <el-input v-model="saveTemplateForm.templateName"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="23">
                            <el-form-item
                                label="描述"
                                prop="lineCategory"
                                style="width: 100%;"
                            >
                                <el-input
                                    :rows="4"
                                    type="textarea"
                                    v-model="saveTemplateForm.commets"
                                ></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </div>
            </el-form>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="saveTemplateForm = false">取消</el-button>
                <el-button
                    type="primary"
                    @click="saveTemplateConfirm()"
                >
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>

    <el-dialog
        v-model="correctionVisible"
        :title="correctionTitle"
        width="792"
    >
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="correctionVisible = false">取消</el-button>
            </div>
        </template>
    </el-dialog>
    <el-dialog
        v-model="tipsDialogVisible"
        title="工作任务概览"
        width="592"
    >
        <div
            class="dialogContent"
            style="width: 500px;padding: 24px 30px;"
        >
            <div class="dialogContentText">总体原则: 上午必须完成COD、氮磷的消解进样</div>
            <div class="dialogContentTitle">水质项目检测：</div>
            <div class="dialogContentText">进水：pH，COD，BOD5，总氮，氨氮，总磷，悬浮物</div>
            <div class="dialogContentText">出水：pH，COD，BOD5，总氮，氨氮，总磷，悬浮物，粪大肠菌群</div>
            <div class="dialogContentTitle">工艺运行参数检测：</div>
            <div class="dialogContentText">生物池末端：DO，SV30，MLSS，MLVSS(每周一次)，SVI，生物相，污泥含水率</div>
        </div>
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="tipsDialogVisible = false">取消</el-button>
            </div>
        </template>
    </el-dialog>
</template>

<script setup>
import Nh3Line from './curveComponents/nh3-n.vue';
import TnLine from './curveComponents/tn.vue';
import TpLine from './curveComponents/tp.vue';
import ConfigOther1600 from './dialogComponents/configOther1600.vue';
import configOther3169_0 from './dialogComponents/configOther3169_0.vue';
import configOther3169_1 from './dialogComponents/configOther3169_1.vue';
import ConfigOther3289 from './dialogComponents/configOther3289.vue';
import ConfigOther2922 from './dialogComponents/configOther2922.vue';
import ConfigOther3277 from './dialogComponents/configOther3277.vue';
import ConfigOther3298 from './dialogComponents/configOther3298.vue';
// utils
import Storage from "@/utils/storage.js";
import fileInfoHttp from "@/https/fileInfo.js";
import {
    ArrowDownBold,
    Delete,
    Edit,
    EditPen,
    Histogram,
    List,
    Opportunity,
    QuestionFilled,
    Picture,
    Refresh,
    FullScreen,
    Close,
    View
} from "@element-plus/icons-vue";
import moment from 'moment';
import { nextTick, onMounted, reactive, ref, watch } from "vue";
// api
import schedulingHttp from "@/https/scheduling.js";
import taskHttp from "@/https/task.js";
import { ElMessage, ElMessageBox } from "element-plus";
import ConfigNormal from './dialogComponents/configNormal.vue';
const fullScreen = ref(false)
const fullscreenFn = () => {
    console.log(111111)
    fullScreen.value = !fullScreen.value
}
// ref
let searchForm = ref({
    depId: Storage.localGet("depId"),
    taskDate: moment().format('YYYY-MM-DD'),
    // taskDate: '2025-03-25',
    onDutyCount: '',
    onDutyName: '',
    taskTemplateId: '',
});
const taskTemplateSort = ref()
const templateName = ref()
const currentTaskTemplateId = ref()
const requiredIdsItems = ref()
const shortcuts = [
    {
        text: "今日",
        value: () => {
            return moment()
        },
    },
    {
        text: "1日前",
        value: () => {
            return moment().add(-1, 'day')
        },
    },
    {
        text: "2日前",
        value: () => {
            return moment().add(-2, 'day')
        },
    },
    {
        text: "5日前",
        value: () => {
            return moment().add(-5, 'day')
        },
    },
];
const userId = ref();
const localTypeUnit = ref();
localTypeUnit.value = Storage.localGet("depId")
userId.value = Storage.localGet("userId")
searchForm.value.depId = localTypeUnit.value == '1' ? '2' : localTypeUnit.value
// searchForm.value.depId = '5'
const chooceTaskVisiable = ref(false);
const checkList = ref([]);
const tableActiveName = ref('process');
const childrensActiveNames = ref(0);
const taskVoListActiveName = ref(0);
const dialogActiveName = ref(0);
const dialogActiveType = ref('1');
const dialogActivePersonalTemplateType = ref('1');
const dialogActiveTypeList = ref([
    { label: "平台模板", value: 1 },
    { label: "个人模板", value: 2 },
    { label: "自定义", value: 3 },
]);
// dict
const depIdList = ref([
    { label: "星沙厂", value: "2" },
    { label: "城西厂", value: "3" },
    { label: "城北厂", value: "4" },
    { label: "城南厂", value: "5" },
    { label: "城东厂", value: "6" },
]);
const depNameTranslate = (depId) => {
    let depName = "";
    depIdList.value.forEach((item) => {
        if (item.value == depId) {
            depName = item.label;
        }
    });
    return depName;
};
const labTeamId = (depId) => {
    let teamId = '1'
    if (depId == 2) {
        teamId = '1'
    } else if (depId == 3) {
        teamId = '1'
    } else if (depId == 4) {
        teamId = '1'
    } else if (depId == 5) {
        teamId = '41'
    } else if (depId == 6) {
        teamId = '1'
    }
    return teamId
}
const hasMember = ref(false)
const memberList = ref([])

// methods
const getTaskMemberList = async () => {
    let teamId = labTeamId(searchForm.value.depId)
    let params = {
        depId: searchForm.value.depId,
        startTime: moment(searchForm.value.taskDate).format('YYYY-MM-DD'),
        endTime: moment(searchForm.value.taskDate).format('YYYY-MM-DD'),
        teamId: labTeamId(searchForm.value.depId),
        userRealName: null,
        classId: null,
        pageNo: 1,
        pageSize: 10,
    }
    const res = await schedulingHttp.workPlanQueryUserWorkPlanPage(params)
    if (res.data.data.records.length > 0) {
        let onDutyNameList = []
        let onDutyIdList = []
        res.data.data.records.forEach(item => {
            onDutyNameList.push(item.realName)
            onDutyIdList.push(item.userId)
        })
        searchForm.value.onDutyCount = res.data.data.records.length
        searchForm.value.onDutyName = onDutyNameList.join('、')
        memberList.value = onDutyIdList
        console.log(memberList.value, 'memberList')
        if (memberList.value.includes(Storage.localGet("userId"))) {
            hasMember.value = false
        } else {
            hasMember.value = true
        }
    } else {
        searchForm.value.onDutyCount = ''
        searchForm.value.onDutyName = ''
        hasMember.value = true
    }
    reportConfigsearch()
}
let templateList = reactive({
    list: []
})
// // 查询
// watch(
//     () => dialogActiveType.value,
//     (val) => {
//         templateList.list.forEach(item => {
//             item[`templatechecked1`] = false
//             item[`templatechecked2`] = false
//             item[`templatechecked3`] = false
//             item[`templatechecked`] = false
//         })
//         if (val == 2) {
//             dialogActivePersonalTemplateType.value = '1'
//             templateListFn(userId.value)
//         } else {
//             templateListFn()
//         }
//     },
//     { deep: true }
// )
// watch(
//     () => dialogActivePersonalTemplateType.value,
//     (val) => {
//         templateList.list.forEach(item => {
//             item[`templatechecked`] = false
//         })
//         if (val == '1') {
//             templateListFn(userId.value)
//         } else {
//             templateListFn('', ' ')
//         }
//     },
//     { deep: true }
// )
const templateListPreson = ref([])
const templateListAll = ref([])
const templateListPresonFn = async () => {
    templateList.list = []
    let params = {
        // depId: depId ? depId : searchForm.value.depId,
        depId: '',
        templateType: 2,
        userId: userId.value
    }
    const res = await taskHttp.queryTaskTemplateList(params)
    let list = []
    list = res.data.data.personn1List.concat(res.data.data.personn2List.concat(res.data.data.personn3List))
    list.forEach(item => {
        item.requiredTitlesItemsList = []
        let itemsList = item.requiredTitlesItems ? item.requiredTitlesItems.split(',') : []
        let itemsIdsList = item.requiredIdsItems ? item.requiredIdsItems.split(',') : []
        itemsList.forEach((m, n) => {
            item.requiredTitlesItemsList.push({
                checked: false,
                itemValue: m,
                itemId: itemsIdsList[n],
            })
        })

        item.requiredTitlesItems2List = []
        let items2List = item.requiredTitlesItems2 ? item.requiredTitlesItems2.split(',') : []
        let itemsIds2List = item.requiredIdsItems2 ? item.requiredIdsItems2.split(',') : []
        items2List.forEach((m, n) => {
            item.requiredTitlesItems2List.push({
                checked: false,
                itemValue: m,
                itemId: itemsIds2List[n],
            })
        })
        item.requiredTitlesItems3List = []
        let items3List = item.requiredTitlesItems3 ? item.requiredTitlesItems3.split(',') : []
        let itemsIds3List = item.requiredIdsItems3 ? item.requiredIdsItems3.split(',') : []
        items3List.forEach((m, n) => {
            item.requiredTitlesItems3List.push({
                checked: false,
                itemValue: m,
                itemId: itemsIds3List[n],
            })
        })
    })
    templateListPreson.value = list
}
const templateListAllFn = async () => {
    templateList.list = []
    let params = {
        // depId: depId ? depId : searchForm.value.depId,
        depId: '',
        templateType: 2,
        // userId: userId
        userId: ''
    }
    const res = await taskHttp.queryTaskTemplateList(params)
    let list = []
    list = res.data.data.personn1List.concat(res.data.data.personn2List.concat(res.data.data.personn3List))
    list.forEach(item => {
        item.requiredTitlesItemsList = []
        let itemsList = item.requiredTitlesItems ? item.requiredTitlesItems.split(',') : []
        let itemsIdsList = item.requiredIdsItems ? item.requiredIdsItems.split(',') : []
        itemsList.forEach((m, n) => {
            item.requiredTitlesItemsList.push({
                checked: false,
                itemValue: m,
                itemId: itemsIdsList[n],
            })
        })

        item.requiredTitlesItems2List = []
        let items2List = item.requiredTitlesItems2 ? item.requiredTitlesItems2.split(',') : []
        let itemsIds2List = item.requiredIdsItems2 ? item.requiredIdsItems2.split(',') : []
        items2List.forEach((m, n) => {
            item.requiredTitlesItems2List.push({
                checked: false,
                itemValue: m,
                itemId: itemsIds2List[n],
            })
        })
        item.requiredTitlesItems3List = []
        let items3List = item.requiredTitlesItems3 ? item.requiredTitlesItems3.split(',') : []
        let itemsIds3List = item.requiredIdsItems3 ? item.requiredIdsItems3.split(',') : []
        items3List.forEach((m, n) => {
            item.requiredTitlesItems3List.push({
                checked: false,
                itemValue: m,
                itemId: itemsIds3List[n],
            })
        })
        item.templateChecked = false
        item.templateChecked1 = false
        item.isIndeterminate1 = false
        item.templateChecked2 = false
        item.isIndeterminate2 = false
        item.templateChecked3 = false
        item.isIndeterminate3 = false
    })
    templateListAll.value = list
}

const requiredTitlesItemsSort = (str) => {
    let sortRes = []
    let strArr = str.split(',')
    taskList.value.forEach(item => {
        strArr.forEach(k => {
            if (item.title == k) {
                sortRes.push(k)
            }
        })
    })
    console.log(sortRes, 'sortRes')
    return sortRes
}
const requiredIdsItemsSort = (str) => {
    let sortRes = []
    let strArr = str.split(',')
    taskList.value.forEach(item => {
        strArr.forEach(k => {
            if (item.id == k) {
                sortRes.push(k)
            }
        })
    })
    console.log(sortRes, 'sortResid')
    return sortRes
}
const templateListFn = async (userId, depId) => {
    templateList.list = []
    let params = {
        // depId: depId ? depId : searchForm.value.depId,
        depId: '',
        templateType: dialogActiveType.value,
        // userId: userId
        userId: ''
    }
    const res = await taskHttp.queryTaskTemplateList(params)
    let list = []
    list = res.data.data.personn1List.concat(res.data.data.personn2List.concat(res.data.data.personn3List))
    list.forEach(item => {
        item.requiredTitlesItemsList = []
        let itemsList = item.requiredTitlesItems ? requiredTitlesItemsSort(item.requiredTitlesItems) : []
        let itemsIdsList = item.requiredIdsItems ? requiredIdsItemsSort(item.requiredIdsItems) : []
        console.log(itemsList, 'itemsList')
        itemsList.forEach((m, n) => {
            item.requiredTitlesItemsList.push({
                checked: false,
                itemValue: m,
                itemId: itemsIdsList[n],
            })
        })

        item.requiredTitlesItems2List = []
        let items2List = item.requiredTitlesItems2 ? requiredTitlesItemsSort(item.requiredTitlesItems2) : []
        let itemsIds2List = item.requiredIdsItems2 ? requiredIdsItemsSort(item.requiredIdsItems2) : []
        items2List.forEach((m, n) => {
            item.requiredTitlesItems2List.push({
                checked: false,
                itemValue: m,
                itemId: itemsIds2List[n],
            })
        })
        item.requiredTitlesItems3List = []
        let items3List = item.requiredTitlesItems3 ? requiredTitlesItemsSort(item.requiredTitlesItems3) : []
        let itemsIds3List = item.requiredIdsItems3 ? requiredIdsItemsSort(item.requiredIdsItems3) : []
        items3List.forEach((m, n) => {
            item.requiredTitlesItems3List.push({
                checked: false,
                itemValue: m,
                itemId: itemsIds3List[n],
            })
        })
        item.templateChecked = false
        item.templateChecked1 = false
        item.isIndeterminate1 = false
        item.templateChecked2 = false
        item.isIndeterminate2 = false
        item.templateChecked3 = false
        item.isIndeterminate3 = false
    })
    templateList.list = list
    console.log(templateList.list, dialogActiveName.value, templateName.value, 'templateList.list')

    if (dialogActiveType.value == '2') {
        templateList.list.forEach((item, index) => {
            if (item.id == currentTaskTemplateId.value) {
                item.templatechecked = true
            }
        })
    } else {
        if (templateName.value == 0 || templateName.value) {
            dialogActiveName.value = templateName.value
            templateList.list.forEach((item, index) => {
                // taskTemplateSort.value = 2
                if (item.id == currentTaskTemplateId.value) {
                    console.log(1, item.id, currentTaskTemplateId.value)
                    if (taskTemplateSort.value && taskTemplateSort.value == 1) {
                        console.log(1)
                        let requiredIdsItemsList = requiredIdsItems.value.split(',')
                        item.requiredTitlesItemsList.forEach(k => {
                            if (requiredIdsItemsList.includes(k.itemId)) {
                                k.checked = true
                            }
                            if (requiredIdsItemsList.length > 0 && requiredIdsItemsList.length < item.requiredTitlesItemsList.length) {
                                item.isIndeterminate1 = true
                            }
                            if (requiredIdsItemsList.length == item.requiredTitlesItemsList.length) {
                                item.templatechecked1 = true
                            }
                        })
                    }
                    if (taskTemplateSort.value && taskTemplateSort.value == 2) {
                        console.log(2)
                        let requiredIdsItemsList = requiredIdsItems.value.split(',')
                        item.requiredTitlesItems2List.forEach(k => {
                            if (requiredIdsItemsList.includes(k.itemId)) {
                                k.checked = true
                            }
                            if (requiredIdsItemsList.length > 0 && requiredIdsItemsList.length < item.requiredTitlesItems2List.length) {
                                item.isIndeterminate2 = true
                            }
                            if (requiredIdsItemsList.length == item.requiredTitlesItems2List.length) {
                                item.templatechecked2 = true
                            }
                        })
                    }
                    if (taskTemplateSort.value && taskTemplateSort.value == 3) {
                        console.log(3)
                        let requiredIdsItemsList = requiredIdsItems.value.split(',')
                        item.requiredTitlesItems3List.forEach(k => {
                            if (requiredIdsItemsList.includes(k.itemId)) {
                                k.checked = true
                            }
                            if (requiredIdsItemsList.length > 0 && requiredIdsItemsList.length < item.requiredTitlesItems3List.length) {
                                item.isIndeterminate3 = true
                            }
                            if (requiredIdsItemsList.length == item.requiredTitlesItems3List.length) {
                                item.templatechecked3 = true
                            }
                        })
                    }
                }
                // item[dialogActiveName.value].forEach(k => {

                // })
            })
        }
    }


    // templateList.list.forEach((item, index) => {
    //     if (item.id == currentTaskTemplateId.value) {
    //         if (dialogActiveType.value == '2') {
    //             item.templatechecked = true
    //         } else {
    //             dialogActiveName.value = templateName.value
    //             if (item.templateName == templateName.value) {
    //                 if (index == 0) {
    //                     item.requiredTitlesItemsList.forEach(k => {
    //                         k.checked = true
    //                     })
    //                 } else {

    //                     item[`requiredTitlesItems${index + 1}List`].forEach(k => {
    //                         k.checked = true
    //                     })
    //                 }
    //             }
    //         }
    //     }
    // })
}
// 选中清空其他
const templatechecked = (val, index, m) => {
    checkList.value = []
    checkList.isIndeterminateAll = false
    checkAll.value = false
    isIndeterminateAll.value = false
    if (val) {
        templateList.list.forEach(item => {
            item[`templatechecked1`] = false
            item[`isIndeterminate1`] = false
            item[`templatechecked2`] = false
            item[`isIndeterminate2`] = false
            item[`templatechecked3`] = false
            item[`isIndeterminate3`] = false
            item[`requiredTitlesItemsList`].forEach(k => {
                k.checked = false
            })
            item[`requiredTitlesItems2List`].forEach(k => {
                k.checked = false
            })
            item[`requiredTitlesItems3List`].forEach(k => {
                k.checked = false
            })
        })
        templateList.list[index][`templatechecked${m}`] = true
        // checkList.value = []
        if (m == 1) {
            templateList.list[index][`requiredTitlesItemsList`].forEach(item => {
                item.checked = true
            })
        } else {
            templateList.list[index][`requiredTitlesItems${m}List`].forEach(item => {
                item.checked = true
            })
        }
        taskTemplateSort.value = m
    } else {
        if (m == 1) {
            templateList.list[index][`requiredTitlesItemsList`].forEach(item => {
                item.checked = false
            })
        } else {
            templateList.list[index][`requiredTitlesItems${m}List`].forEach(item => {
                item.checked = false
            })
        }
    }

}
//自定义全选
const checkAll = ref(false)
const isIndeterminateAll = ref(false)
const checkType1 = ref(false)
const isIndeterminateType1 = ref(false)
const checkType2 = ref(false)
const isIndeterminateType2 = ref(false)
const checkType3 = ref(false)
const isIndeterminateType3 = ref(false)
const handleCheckAllChangeAll = (v) => {
    console.log(v)
    if (v) {
        checkList.value = []
        taskList.value.forEach(item => {
            checkList.value.push(item.id)
        })
        checkType1.value = true
        checkType2.value = true
        checkType3.value = true
        isIndeterminateType1.value = false
        isIndeterminateType2.value = false
        isIndeterminateType3.value = false
        isIndeterminateAll.value = false
    } else {
        checkList.value = []
        checkType1.value = false
        checkType2.value = false
        checkType3.value = false
        isIndeterminateType1.value = false
        isIndeterminateType2.value = false
        isIndeterminateType3.value = false
        isIndeterminateAll.value = false
    }
    templateListPreson.value.forEach(item => {
        item.templatechecked = false
    })
    templateListAll.value.forEach(item => {
        item.templatechecked = false
    })
    templateListClear()
}
const handleCheckAllChangeType = (v, type) => {
    console.log(v)
    if (v) {
        taskList.value.forEach(item => {
            if (item.taskCategory == type) {
                checkList.value.push(item.id)
            }
        })
    } else {
        taskList.value.forEach(item => {
            if (item.taskCategory == type) {
                console.log(item.id, item.taskCategory)
                checkList.value.forEach((k, l) => {
                    if (item.id == k) {
                        checkList.value.splice(l, 1)
                    }
                })
            }
        })
    }
    console.log(1111)
    let len = taskList.value.length
    checkAll.value = checkList.value.length == len
    isIndeterminateAll.value = checkList.value.length > 0 && checkList.value.length < len
    templateListClear()
    templateListPreson.value.forEach(item => {
        item.templatechecked = false
    })
    templateListAll.value.forEach(item => {
        item.templatechecked = false
    })
    templateListClear()
}
const handleCheckedChange = () => {
    let type1 = 0
    let type2 = 0
    let type3 = 0
    let checkAlltype1 = 0
    let checkAlltype2 = 0
    let checkAlltype3 = 0
    taskList.value.forEach(item => {
        if (item.taskCategory == '1') {
            type1++
        }
        if (item.taskCategory == '2') {
            type2++
        }
        if (item.taskCategory == '3') {
            type3++
        }
        checkList.value.forEach(k => {
            if (item.taskCategory == '1' && item.id == k) {
                checkAlltype1++
            }
            if (item.taskCategory == '2' && item.id == k) {
                checkAlltype2++
            }
            if (item.taskCategory == '3' && item.id == k) {
                checkAlltype3++
            }
        })
    })

    console.log(type1, type2, type3, checkAlltype1, checkAlltype2, checkAlltype3)
    console.log(checkAlltype2 > 0 && checkAlltype2 < type2)
    let len = taskList.value.length
    checkAll.value = checkList.value.length == len
    isIndeterminateAll.value = checkList.value.length > 0 && checkList.value.length < len
    checkType1.value = checkAlltype1 == type1
    isIndeterminateType1.value = checkAlltype1 > 0 && checkAlltype1 < type1
    checkType2.value = checkAlltype2 == type2
    isIndeterminateType2.value = checkAlltype2 > 0 && checkAlltype2 < type2
    checkType3.value = checkAlltype3 == type3
    isIndeterminateType3.value = checkAlltype3 > 0 && checkAlltype3 < type3
    templateListClear()
}
watch(
    () => templateList.list,
    (val) => {
        console.log(templateList, 'val')
    },
    { deep: true }
)
// 选中清空templateList所有
const templateListClear = () => {
    console.log(templateList, '222222')
    templateList.list.forEach(item => {
        item[`templatechecked1`] = false
        item[`isIndeterminate1`] = false
        item[`templatechecked2`] = false
        item[`isIndeterminate2`] = false
        item[`templatechecked3`] = false
        item[`isIndeterminate3`] = false
        item.requiredTitlesItemsList.forEach(k => {
            k.checked = false
        })
        item.requiredTitlesItems2List.forEach(k => {
            k.checked = false
        })
        item.requiredTitlesItems3List.forEach(k => {
            k.checked = false
        })
    })
    console.log(templateList)
}
// 选中清空其他
const templatecheckedChild = (val, index, m) => {
    console.log(val, index, m)
    taskTemplateSort.value = m
    checkList.value = []
    isIndeterminateAll.value = false
    templateListPreson.value.forEach(item => {
        item.templatechecked = false
    })
    templateListAll.value.forEach(item => {
        item.templatechecked = false
    })
    if (val) {
        templateList.list.forEach(item => {
            item[`templatechecked1`] = false
            item[`isIndeterminate1`] = false
            item[`templatechecked2`] = false
            item[`isIndeterminate2`] = false
            item[`templatechecked3`] = false
            item[`isIndeterminate3`] = false
        })
        templateList.list[index][`templatechecked${m}`] = true
        // checkList.value = []
        templateList.list.forEach((item, i) => {
            if (index != i) {
                item.requiredTitlesItemsList.forEach(k => {
                    k.checked = false
                })
                item.requiredTitlesItems2List.forEach(k => {
                    k.checked = false
                })
                item.requiredTitlesItems3List.forEach(k => {
                    k.checked = false
                })
            } else {
                if (m == 1) {
                    item.requiredTitlesItems2List.forEach(k => {
                        k.checked = false
                    })
                    item.requiredTitlesItems3List.forEach(k => {
                        k.checked = false
                    })
                }
                if (m == 2) {
                    item.requiredTitlesItemsList.forEach(k => {
                        k.checked = false
                    })
                    item.requiredTitlesItems3List.forEach(k => {
                        k.checked = false
                    })
                }
                if (m == 3) {
                    item.requiredTitlesItemsList.forEach(k => {
                        k.checked = false
                    })
                    item.requiredTitlesItems2List.forEach(k => {
                        k.checked = false
                    })
                }
            }
        })
        taskTemplateSort.value = m
    } else {
        // let len = templateList.list[index][`requiredTitlesItems${m == 1 ? '':m}List`].length
        let checkedNumb = 0
        templateList.list[index][`requiredTitlesItems${m == 1 ? '' : m}List`].forEach(k => {
            if (k.checked) {
                checkedNumb = checkedNumb + 1
            }
        })
        console.log(checkedNumb)

        if (checkedNumb == 0) {
            templateList.list[index][`templatechecked${m}`] = false
        }
    }
    if (m == 1) {
        let checkedNumb = 0
        let len = templateList.list[index].requiredTitlesItemsList.length
        templateList.list[index].requiredTitlesItemsList.forEach(k => {
            if (k.checked) {
                console.log(k)
                checkedNumb = checkedNumb + 1
            }
        })
        templateList.list[index].templatechecked1 = checkedNumb == len
        templateList.list[index].isIndeterminate1 = checkedNumb > 0 && checkedNumb < len
        console.log(templateList.list[index], checkedNumb, len, 'templateList.list[index]')
    }
    if (m == 2) {
        let checkedNumb = 0
        let len = templateList.list[index].requiredTitlesItems2List.length
        templateList.list[index].requiredTitlesItems2List.forEach(k => {
            if (k.checked) {
                console.log(k)
                checkedNumb = checkedNumb + 1
            }
        })
        templateList.list[index].templatechecked2 = checkedNumb == len
        templateList.list[index].isIndeterminate2 = checkedNumb > 0 && checkedNumb < len
        console.log(templateList.list[index], checkedNumb, len, 'templateList.list[index]')
    }
    if (m == 3) {
        let checkedNumb = 0
        let len = templateList.list[index].requiredTitlesItems3List.length
        templateList.list[index].requiredTitlesItems3List.forEach(k => {
            if (k.checked) {
                console.log(k)
                checkedNumb = checkedNumb + 1
            }
        })
        templateList.list[index].templatechecked3 = checkedNumb == len
        templateList.list[index].isIndeterminate3 = checkedNumb > 0 && checkedNumb < len
        console.log(templateList.list[index], checkedNumb, len, 'templateList.list[index]')
    }
}
watch(
    () => taskTemplateSort.value,
    (val) => {
        console.log(val, 'taskTemplateSort.value')
    }
)
// 选中清空其他
const personalTemplatecheckedPreson = (val, row, index) => {
    checkAll.value = false
    isIndeterminateAll.value = false
    templateListClear()
    if (val) {
        templateListPreson.value.forEach(item => {
            item.templatechecked = false
        })
        templateListAll.value.forEach(item => {
            item.templatechecked = false
        })
        templateListPreson.value[index].templatechecked = true
        // checkList.value = []
        console.log(val, templateListPreson.value)
    }
}
// 选中清空其他
const personalTemplatecheckedAll = (val, row, index) => {
    checkAll.value = false
    isIndeterminateAll.value = false
    templateListClear()
    if (val) {
        templateListPreson.value.forEach(item => {
            item.templatechecked = false
        })
        templateListAll.value.forEach(item => {
            item.templatechecked = false
        })
        templateListAll.value[index].templatechecked = true
        // checkList.value = []
    }
}
const taskList = ref([])
// 查询
const taskListFn = async () => {
    const res = await taskHttp.queryTaskList(searchForm.value)
    taskList.value = res.data.data
    templateListFn()
}

const taskListIdToName = (taskIds) => {
    let taskName = []
    let taskIdsList = taskIds.split(',')
    taskIdsList.forEach(item => {
        taskList.value.forEach(m => {
            if (item == m.id) {
                taskName.push(m.title)
            }
        })
    })
    return taskName.join(',')
}

// 选择今日任务
const chooceTodayTask = async () => {
    chooceTaskVisiable.value = true
    checkList.value = []
    checkAll.value = false
    templateListClear()
    console.log(currentTaskTemplateId.value, 'currentTaskTemplateId.value')
    if (currentTaskTemplateId.value) {
        let params = {
            depId: "",
            personnelNum: "",
            templateName: ""
        }
        const res = await taskHttp.queryTaskTemplateList(params)
        let tmpType
        res.data.data.personn1List.forEach(item => {
            if (item.id == currentTaskTemplateId.value) {
                tmpType = item.templateType
                templateName.value = 0
            }
        })
        res.data.data.personn2List.forEach(item => {
            if (item.id == currentTaskTemplateId.value) {
                tmpType = item.templateType
                templateName.value = 1
            }
        })
        res.data.data.personn3List.forEach(item => {
            if (item.id == currentTaskTemplateId.value) {
                tmpType = item.templateType
                templateName.value = 2
            }
        })
        console.log(tmpType, 'tmpType')
        dialogActiveType.value = tmpType + ''
        if (dialogActiveType.value == '2') {
            templateListPreson.value.forEach(item => {
                if (item.id == currentTaskTemplateId.value) {
                    item.templatechecked = true
                    dialogActivePersonalTemplateType.value = '1'
                }
            })
            templateListAll.value.forEach(item => {
                if (item.id == currentTaskTemplateId.value) {
                    item.templatechecked = true
                    dialogActivePersonalTemplateType.value = '2'
                }
            })
        } else {
            dialogActiveName.value = templateName.value
            templateList.list.forEach((item, index) => {
                // taskTemplateSort.value = 2
                if (item.id == currentTaskTemplateId.value) {
                    console.log(1, item.id, currentTaskTemplateId.value, taskTemplateSort.value)
                    if (taskTemplateSort.value && taskTemplateSort.value == 1) {
                        console.log(1)
                        let requiredIdsItemsList = requiredIdsItems.value.split(',')
                        item.requiredTitlesItemsList.forEach(k => {
                            if (requiredIdsItemsList.includes(k.itemId)) {
                                k.checked = true
                            }
                            if (requiredIdsItemsList.length > 0 && requiredIdsItemsList.length < item.requiredTitlesItemsList.length) {
                                item.isIndeterminate1 = true
                            }
                            if (requiredIdsItemsList.length == item.requiredTitlesItemsList.length) {
                                item.templatechecked1 = true
                            }
                        })
                    }
                    if (taskTemplateSort.value && taskTemplateSort.value == 2) {
                        console.log(2)
                        let requiredIdsItemsList = requiredIdsItems.value.split(',')
                        item.requiredTitlesItems2List.forEach(k => {
                            if (requiredIdsItemsList.includes(k.itemId)) {
                                k.checked = true
                            }
                            if (requiredIdsItemsList.length > 0 && requiredIdsItemsList.length < item.requiredTitlesItems2List.length) {
                                item.isIndeterminate2 = true
                            }
                            if (requiredIdsItemsList.length == item.requiredTitlesItems2List.length) {
                                item.templatechecked2 = true
                            }
                        })
                    }
                    if (taskTemplateSort.value && taskTemplateSort.value == 3) {
                        console.log(3)
                        let requiredIdsItemsList = requiredIdsItems.value.split(',')
                        item.requiredTitlesItems3List.forEach(k => {
                            if (requiredIdsItemsList.includes(k.itemId)) {
                                k.checked = true
                            }
                            if (requiredIdsItemsList.length > 0 && requiredIdsItemsList.length < item.requiredTitlesItems3List.length) {
                                item.isIndeterminate3 = true
                            }
                            if (requiredIdsItemsList.length == item.requiredTitlesItems3List.length) {
                                item.templatechecked3 = true
                            }
                        })
                    }
                }
                // item[dialogActiveName.value].forEach(k => {

                // })
            })
        }
    } else {
        // 自定义模板
        if (requiredIdsItems.value) {
            dialogActiveType.value = '3'
            const list = requiredIdsItems.value.split(',')
            list.forEach(item => {
                checkList.value.push(Number(item))
            })
            let len = taskList.value.length
            checkAll.value = checkList.value.length == len
            isIndeterminateAll.value = checkList.value.length > 0 && checkList.value.length < len
        } else {
            dialogActiveType.value = '1'
        }
    }
}
// 确认今日任务
const chooceTaskConfirm = async () => {
    let params = {
        depId: searchForm.value.depId,
        requiredIdsItems: '',
        requiredTitlesItems: '',
        taskDate: moment(searchForm.value.taskDate).format('YYYY-MM-DD'),
        userId: '',
        taskTemplateId: '',
        createTime: '',
        updateTime: '',
        taskTemplateSort: taskTemplateSort.value
    }
    console.log(dialogActiveType.value, 'dialogActiveType.value')
    if (dialogActiveType.value == '3') {
        if (checkList.value.length > 0) { // 选了自定义
            params.taskTemplateId = ''
            params.requiredIdsItems = checkList.value.join(',')
            params.requiredTitlesItems = taskListIdToName(params.requiredIdsItems)
            console.log(params, 'params')
        }
    } else if (dialogActiveType.value == '1') {
        templateList.list.forEach(item => {
            if (item[`templatechecked1`] || item[`isIndeterminate1`]) {
                let idsList = []
                let titlesList = []
                item.requiredTitlesItemsList.forEach((m, n) => {
                    if (m.checked) {
                        idsList.push(m.itemId)
                        titlesList.push(m.itemValue)
                    }
                })
                params.requiredIdsItems = idsList.join(',')
                params.requiredTitlesItems = titlesList.join(',')
                params.taskTemplateId = item.id
                console.log(params, 'params')
            }
            if (item[`templatechecked2`] || item[`isIndeterminate2`]) {
                let idsList = []
                let titlesList = []
                item.requiredTitlesItems2List.forEach((m, n) => {
                    if (m.checked) {
                        idsList.push(m.itemId)
                        titlesList.push(m.itemValue)
                    }
                })
                params.requiredIdsItems = idsList.join(',')
                params.requiredTitlesItems = titlesList.join(',')
                console.log(params, 'params')
                params.taskTemplateId = item.id
            }
            if (item[`templatechecked3`] || item[`isIndeterminate3`]) {
                let idsList = []
                let titlesList = []
                item.requiredTitlesItems3List.forEach((m, n) => {
                    if (m.checked) {
                        idsList.push(m.itemId)
                        titlesList.push(m.itemValue)
                    }
                })
                params.requiredIdsItems = idsList.join(',')
                params.requiredTitlesItems = titlesList.join(',')
                console.log(params, 'params')
                params.taskTemplateId = item.id
            }
        })
    } else {
        templateList.list.forEach(item => {
            if (item.templatechecked) {
                params.requiredIdsItems = item.requiredIdsItems
                params.requiredTitlesItems = item.requiredTitlesItems
                params.taskTemplateId = item.id
                console.log(params, 'params')
            }
        })

        templateListPreson.value.forEach(item => {
            if (item.templatechecked) {
                params.requiredIdsItems = item.requiredIdsItems
                params.requiredTitlesItems = item.requiredTitlesItems
                params.taskTemplateId = item.id
                console.log(params, 'params')
            }
        })
        templateListAll.value.forEach(item => {
            if (item.templatechecked) {
                params.requiredIdsItems = item.requiredIdsItems
                params.requiredTitlesItems = item.requiredTitlesItems
                params.taskTemplateId = item.id
                console.log(params, 'params')
            }
        })
    }
    console.log(params, 'ppppppppppp')
    if (params.requiredIdsItems) {
        if (myTask.value.length > 0) {
            params.id = myTaskObj.value.id
            params.createTime = ''
            params.updateTime = ''
            const res = await taskHttp.updateUserLabtask(params)
        } else {
            const res = await taskHttp.addUserLabtask(params)
        }
        chooceTaskVisiable.value = false
        search()
    } else {
        ElMessage({
            message: '请选择模板！',
            type: 'warning'
        })
    }
}
const allTask = ref([])
const myTask = ref([])
const myPersonalTask = ref([])
const taskCategoryType = ref(1)
const myTaskObj = ref({})
const allTaskObj = ref({})
const myTaskReportContent = ref([])
const process = ref('')
const allTaskReportContent = ref([])
// 查询
const search = async (type) => {
    allTask.value = []
    myTask.value = []
    // 全部任务
    let params = {
        depId: searchForm.value.depId,
        taskDate: moment(searchForm.value.taskDate).format('YYYY-MM-DD'),
        userId: ''
    }
    const res = await taskHttp.queryUserLabtaskList(params)
    allTask.value.taskVoList = []
    allTask.value = res.data.data

    // 我的任务
    let params2 = {
        depId: searchForm.value.depId,
        taskDate: moment(searchForm.value.taskDate).format('YYYY-MM-DD'),
        userId: Storage.localGet("userId")
    }
    const res2 = await taskHttp.queryUserLabtaskBydate(params2)
    taskTemplateSort.value = res2.data.data.taskTemplateSort ? res2.data.data.taskTemplateSort : ''
    currentTaskTemplateId.value = res2.data.data.taskTemplateId
    requiredIdsItems.value = res2.data.data.requiredIdsItems
    let myList = []
    myTaskObj.value.taskVoList = []
    myTaskObj.value = res2.data.data
    if (res2.data.data && res2.data.data.id) {
        let checkedList = res2.data.data.reportContent ? JSON.parse(res2.data.data.reportContent) : []
        let checkedIdList = []
        checkedList.length > 0 && checkedList.forEach(item => {
            if (item.processResultChecked) {
                checkedIdList.push(item.taskId)
            }
        })
        res2.data.data.taskVoList && res2.data.data.taskVoList.forEach(item => {
            taskToConfig(item)
            if (item.childrens && item.childrens.length > 0) {
                item.childrens.forEach(m => {
                    console.log(m.isNess, 'isNess')
                    item.lineId = ''
                    if (m.childrens && m.childrens.length > 0) {
                        m.childrens.forEach(p => {
                            p.taskId = p.id
                            if (checkedIdList.includes(p.id)) {
                                p.processResultChecked = true
                                // p.lineId = p.
                            } else {
                                p.processResultChecked = false
                            }
                            myList.push({
                                parentParentId: item.id,
                                parentId: m.id,
                                taskId: p.id,
                                id: item.id,
                                considerationsFileId: p.considerationsFileId,
                                considerationsFileIdUrl: '',
                                title: item.title,
                                stepId: m.id,
                                stepTitle: m.title,
                                decomposeStepId: p.id,
                                decomposeStepTitle: p.title,
                                isNess: m.isNess,
                                time: '',
                                content: p.description,
                                complianceScope: '',
                                location: p.location,
                                checkResult: '',
                                considerations: p.considerations,
                                processResultChecked: false,
                                finishTime: null,
                                taskCategory: item.taskCategory,
                                lineId: ''
                            })
                        })
                    } else {
                        myList.push({
                            parentParentId: '',
                            parentId: item.id,
                            taskId: m.id,
                            id: item.id,
                            title: item.title,
                            stepId: m.id,
                            stepTitle: m.title,
                            decomposeStepId: '',
                            decomposeStepTitle: '',
                            isNess: m.isNess,
                            time: '',
                            content: '',
                            complianceScope: '',
                            location: '',
                            checkResult: '',
                            processResultChecked: false,
                            finishTime: null,
                            taskCategory: item.taskCategory,
                            lineId: ''
                        })
                    }
                })
            } else {
                myList.push({
                    parentParentId: '',
                    parentId: '',
                    taskId: item.id,
                    id: item.id,
                    title: item.title,
                    stepId: '',
                    stepTitle: '',
                    decomposeStepId: '',
                    decomposeStepTitle: '',
                    time: '',
                    content: '',
                    complianceScope: '',
                    location: '',
                    checkResult: '',
                    processResultChecked: false,
                    finishTime: null,
                    taskCategory: item.taskCategory,
                    lineId: ''
                })
            }
        })
        console.log(myList, 'myList')
        if (res2.data.data.taskTemplatePo) {
            let myTaskTemplateTimesetVos = JSON.parse(res2.data.data.taskTemplatePo.taskTemplateTimesetVos)
            myList.forEach((item, index) => {
                myTaskTemplateTimesetVos.forEach((k, l) => {
                    if (item.taskId == k.id) {
                        // console.log(item.taskId, k.id, item, k)
                        item.planStartTime = myTaskTemplateTimesetVos[l].planStartTime || ''
                        item.planEndTime = myTaskTemplateTimesetVos[l].planEndTime || ''
                        taskToConfig(item)
                    }
                })
            })
            console.log(myList, 'myList')
        }
        myTaskReportContent.value = []
        if (!myTaskObj.value.reportContent) {
            myTaskObj.value.reportContent = []
            let processTaskAll = 0
            myList.forEach((item, index) => {
                if (item.isNess != 0) {
                    processTaskAll++
                }
                myTaskReportContent.value.push({
                    processResultChecked: false,
                    taskId: item.taskId,
                    title: item.title,
                    isNess: item.isNess,
                    parentId: item.parentId,
                    parentParentId: item.parentParentId,
                    lineId: item.lineId,
                    finishTime: null,
                })
            })

            process.value = `0 / ${processTaskAll}`
            console.log(myTaskReportContent.value, myList, 'myTaskReportContent.add')
        } else {
            myTaskReportContent.value = JSON.parse(myTaskObj.value.reportContent)
            console.log(myTaskReportContent.value, 'myTaskReportContent.add')
            let processResultCheckedNumb = 0
            let processTaskAll = 0
            myTaskReportContent.value.forEach(item => {
                console.log(item.isNess)
                if (item.isNess != 0) {
                    processTaskAll++
                }
                if (item.processResultChecked && item.isNess != 0) {
                    processResultCheckedNumb++
                }
                myList.forEach(m => {
                    if (item.taskId == m.taskId) {
                        m.processResultChecked = item.processResultChecked
                        m.finishTime = item.finishTime
                    }
                    if (item.parentId == m.parentId) {
                        m.lineId = item.lineId
                    }
                })

                res2.data.data.taskVoList.forEach(m => {
                    if (m.id == 3280 || m.id == 3283 || m.id == 3286) {
                        m.childrens.forEach(k => {
                            if (k.id == item.parentId) {
                                // console.log(k.id, item.parentId, item, 'k')
                                k.lineId = item.lineId
                            }
                        })
                    }
                })
            })
            process.value = `${processResultCheckedNumb} / ${processTaskAll}`
            console.log(processResultCheckedNumb, processTaskAll, process.value, 'myTaskReportContent.edit')
            // myTaskObj.value.reportContent = []
            // myList.forEach((item, index) => {
            //     myTaskReportContent.value.push(false)
            // })
        }
    }
    let haveTimeList = myList.filter(item => item.planStartTime !== undefined && item.planStartTime !== null && item.planStartTime !== "");
    let noTimeList = myList.filter(item => item.planStartTime == undefined || item.planStartTime == null || item.planStartTime == "");
    console.log(haveTimeList, noTimeList, 'haveTimeList, noTimeList')
    haveTimeList.sort(function (a, b) {
        searchForm.value.taskDate = moment(searchForm.value.taskDate).format('YYYY-MM-DD')
        return moment(`${searchForm.value.taskDate} ${a.planStartTime}`).valueOf() - moment(`${searchForm.value.taskDate} ${b.planStartTime}`).valueOf()
    })
    myTask.value = haveTimeList.concat(noTimeList)
    if (res2.data.data.id) {
        if (res2.data.data.taskTemplateId) {
            taskCategoryType.value = 1
            tableActiveName.value = 'process'
        } else {
            taskCategoryType.value = 2
            tableActiveName.value = 'my'
            let showList = []
            myList.forEach(item => {
                if (item.processResultChecked) {
                    showList.push(item)
                }
            })
            myPersonalTask.value = showList
        }
        console.log(taskCategoryType.value, 'taskCategoryType')
    }
    if (!res2.data.data.id) {
        chooceTaskVisiable.value = true
    }
}
const finishCheckChange = async (val, row) => {
    if (row.stepTitle == '曲线的绘制') {
        console.log(val)
        if (!val) {
            console.log(myTask.value)
            myTaskObj.value.createTime = ''
            myTaskObj.value.updateTime = ''
            myTaskReportContent.value.forEach(item => {
                myTask.value.forEach(m => {
                    if (item.taskId == row.taskId) {
                        item.processResultChecked = row.processResultChecked
                    }
                })
            })
            myTaskObj.value.reportContent = JSON.stringify(myTaskReportContent.value)
            if (tableActiveName.value == 'my') {
                const res = await taskHttp.updateUserLabtask(myTaskObj.value)
            }
        } else {
            row.processResultChecked = false
            handleDrawingClick(row)
        }
    } else {
        myTaskObj.value.createTime = ''
        myTaskObj.value.updateTime = ''
        myTaskReportContent.value.forEach(item => {
            if (item.taskId == row.taskId) {
                item.processResultChecked = row.processResultChecked
                if (val) {
                    console.log(val)
                    item.finishTime = moment().format('HH:mm')
                } else {
                    item.finishTime = null
                }
            }
        })
        myTaskObj.value.reportContent = JSON.stringify(myTaskReportContent.value)
        if (tableActiveName.value == 'process' || tableActiveName.value == 'my') {
            const res = await taskHttp.updateUserLabtask(myTaskObj.value)
            search()
        }
    }
    console.log(myTask.value, 'myTask')
}
const reportConfigList = ref([])
const reportConfigTotal = ref([])
// 查询
const reportConfigsearch = async () => {
    const res = await taskHttp.reportPropertiesPageList(searchForm.value)
    res.data.data.records.forEach(item => {
        let arr = []
        let relationDailyItem = []
        item.relatedIndicatorList.forEach(m => {
            relationDailyItem.push(m.indicatorName)
            m.indicatorDetailList.forEach(p => {
                p.result = ''
                arr.push({
                    indicatorName: m.indicatorName,
                    ...p
                })
            })
        })
        item.relationDailyItemName = relationDailyItem.join('、')
        item.relatedIndicatorPlatList = arr
    })
    reportConfigList.value = res.data.data.records
    reportConfigTotal.value = res.data.data.total
    console.log(reportConfigList.value, 'reportConfigList.value')
    search()
}
const taskToConfig = (taskItem) => {
    reportConfigList.value.forEach(item => {
        if (taskItem.id == item.title) {
            taskItem.relatedIndicatorPlatList = item.relatedIndicatorPlatList
            taskItem.reportConfigId = item.id
        }
    })
}
const getTaskToConfigById = (id) => {
    let config = {}
    reportConfigList.value.forEach(item => {
        if (item.id == id) {
            config = item
        }
    })
    return config
}
const correctionVisible = ref(false)
const correctionTitle = ref('修正记录')

const configVisible = ref(false)
const configTitle = ref('')
const configOtherVisible = ref(false)
const configOtherTitle = ref('')

const paintVisible = ref(false)
const paintForm = ref({
    lineId: '',
    parentParentId: '',
    parentId: '',
})
const handleDrawingClick = (row, type, lineCategoryId) => {
    console.log(row, '==========')
    paintVisible.value = true
    paintForm.value = row
    paintForm.value.lineId = row.lineId
    if (type == 'my') {
        paintForm.value.parentId = row.id
    }
    // row.lineCategory = lineCategoryId == 3280 ? 2 : lineCategoryId == 3283 ? 1 : lineCategoryId == 3286 ? 3 : ''
    linearEquationPaint(row.lineCategory)
}
const lineCategoryList = ref([
    { label: "全部", value: "" },
    { label: "NH₃-N曲线", value: "1" },
    { label: "TN曲线", value: "2" },
    { label: "TP曲线", value: "3" },
]);
const isQualifiedList = ref([
    { label: "全部", value: "" },
    { label: "合格", value: "1" },
    { label: "不合格", value: "2" },
]);
const linearEquationPaintList = ref([])
const linearEquationPaint = async (type) => {
    let params = {
        ...linearSearchForm,
        depId: searchForm.value.depId,
        pageSize: 1000,
        pageNo: searchForm.value.pageNo,
    }
    const res = await taskHttp.queryLinearEquationList(params)
    linearEquationPaintList.value = res.data.data.records
}
const paintConfirm = async () => {
    if (paintForm.value.lineId) {
        myTask.value.forEach(item => {
            if (item.parentId == paintForm.value.parentId) {
                item.lineId = paintForm.value.lineId
                console.log(item, 'item')
            }
        })
        myTaskReportContent.value.forEach(item => {
            myTask.value.forEach(m => {
                if (item.parentId == m.parentId) {
                    item.lineId = m.lineId
                }
            })
        })
        myTaskObj.value.reportContent = JSON.stringify(myTaskReportContent.value)
        myTaskObj.value.createTime = ''
        myTaskObj.value.updateTime = ''
        if (tableActiveName.value == 'my' || tableActiveName.value == 'process') {
            const res = await taskHttp.updateUserLabtask(myTaskObj.value)
            search()
        }
        paintVisible.value = false
    }
}
const handleClickType = ref()
const handleClickTaskType = ref()
const configOther3289Ref = ref(null)
const configOther1600Ref = ref(null)
const configOther3169Ref = ref(null)
const configOther2922Ref = ref(null)
const configOther3277Ref = ref(null)
const configOther3298Ref = ref(null)
const configNormalRef = ref(null)
const MLSS_MLVSS_NAME_INDEX = ref(0)
const relatedIndicatorchange = (v) => {
    MLSS_MLVSS_NAME_INDEX.value = v
}
const configOther3169Ref_0 = ref(null)
const configOther3169Ref_1 = ref(null)
const editListVisible = ref(false)
const handleClick = async (type, row) => {
    console.log(row, 'row')
    handleClickType.value = type
    handleClickTaskType.value = row.id
    if (type == 'report' || type == 'update' || type == 'edit') {
        console.log(row, 'row11111')

        if (handleClickTaskType.value == 2922) {
            configOtherVisible.value = true
            configOtherTitle.value = row.title + '测试'
            nextTick(() => {
                console.log(configOther2922Ref.value, 'configOther2922Ref.value')
                configOther2922Ref.value.init(type, row)
            })
        } else if (handleClickTaskType.value == 3298) {
            configOtherVisible.value = true
            configOtherTitle.value = row.title + '测试'
            nextTick(() => {
                console.log(configOther3298Ref.value, 'configOther3298Ref.value')
                configOther3298Ref.value.init(type, row)
            })
        } else if (handleClickTaskType.value == 3277) {
            configOtherVisible.value = true
            configOtherTitle.value = row.title + '测试'
            nextTick(() => {
                console.log(configOther3277Ref.value, 'configOther3277Ref.value')
                configOther3277Ref.value.init(type, row)
            })

        } else if (handleClickTaskType.value == 3289) {
            configOtherVisible.value = true
            configOtherTitle.value = row.title + '测试'
            nextTick(() => {
                console.log(configOther3289Ref.value, 'configOther3289Ref.value')
                configOther3289Ref.value.init(type, row)
            })

        } else if (handleClickTaskType.value == 1600) {
            configOtherVisible.value = true
            configOtherTitle.value = row.title
            nextTick(() => {
                console.log(configOther1600Ref.value, 'configOther1600Ref.value')
                configOther1600Ref.value.init(type, row)
            })

        } else if (handleClickTaskType.value == 3169) {
            configOtherVisible.value = true
            configOtherTitle.value = row.title
            nextTick(() => {
                console.log(configOther3169Ref_0.value, 'configOther3169Ref_0.value')
                configOther3169Ref_0.value.init(type, row)
            })
            nextTick(() => {
                console.log(configOther3169Ref_1.value, 'configOther3169Ref_1.value')
                configOther3169Ref_1.value.init(type, row)
            })
        } else {
            configVisible.value = true
            configTitle.value = row.title
            nextTick(() => {
                configNormalRef.value.init(type, row)
            })
        }

    } else if (type == 'editList') {
        let params = {
            depId: searchForm.value.depId,
            entryDate: moment(searchForm.value.taskDate).format('YYYY-MM-DD'),
            taskId: row.taskId,
            reportType: '修正'
        }
        const res = await taskHttp.queryResult(params)
        console.log(res, res.data.data)
        // editListVisible.value = true
    }
}
const configNormalConfirm = () => {
    nextTick(() => {
        configNormalRef.value.resultValueConfirm()
    })
}
const configOtherConfirm = (type) => {
    if (type == 3289) {
        nextTick(() => {
            configOther3289Ref.value.resultValueConfirm()
        })
    }
    if (type == 1600) {
        nextTick(() => {
            configOther1600Ref.value.resultValueConfirm()
        })
    }
    if (type == 2922) {
        nextTick(() => {
            configOther2922Ref.value.resultValueConfirm()
        })
    }
    if (type == 3277) {
        nextTick(() => {
            configOther3277Ref.value.resultValueConfirm()
        })
    }
    if (type == 3298) {
        nextTick(() => {
            configOther3298Ref.value.resultValueConfirm()
        })
    }
    if (type == 3169) {
        nextTick(() => {
            configOther3169Ref_0.value.resultValueConfirm()
        })
        nextTick(() => {
            configOther3169Ref_1.value.resultValueConfirm()
        })
    }
}
const timeTipClass = (row, index) => {
    let className = ''
    let today = moment().format('YYYY-MM-DD')
    let todayTime = moment().format('YYYY-MM-DD HH:mm:ss')
    let start = moment(searchForm.value.taskDate).format('YYYY-MM-DD') + ` ${row.planStartTime}`
    let end = moment(searchForm.value.taskDate).format('YYYY-MM-DD') + ` ${row.planEndTime}`
    let currentPlanStartTime = moment(start).format('YYYY-MM-DD HH:mm:ss')
    let currentPlanEndTime = moment(end).format('YYYY-MM-DD HH:mm:ss')
    if (row.processResultChecked) {
        className = 'success'
    } else if (moment(currentPlanEndTime).isBefore(moment(todayTime))) {
        className = 'danger'
    } else if (moment(todayTime).isBefore(moment(currentPlanEndTime)) && moment(currentPlanStartTime).isBefore(moment(todayTime))) {
        className = 'warning'
    } else if (moment(todayTime).isBefore(moment(currentPlanStartTime))) {
        className = 'nomarl'
    }
    return className
}

const drawingList = ref([])
const drawingListTotal = ref(0)
const handleSizeChange = (val) => {
    linearSearchForm.value.pageSize = val;
};
const handleCurrentChange = (val) => {
    linearSearchForm.value.pageNo = val;
};
const linearSearchForm = ref({
    lineName: '',
    dateTime: [moment().add(-7, 'day').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')],
    lineCategory: "",
    isQualified: "",
    pageNo: 1,
    pageSize: 10,
})
const searchDrawingList = async () => {
    let params = {
        ...linearSearchForm.value,
        depId: searchForm.value.depId,
    }
    params.startTime = linearSearchForm.value.dateTime ? moment(linearSearchForm.value.dateTime[0]).format("YYYY-MM-DD") : ''
    params.endTime = linearSearchForm.value.dateTime ? moment(linearSearchForm.value.dateTime[1]).format("YYYY-MM-DD") : ''
    console.log(params)
    const res = await taskHttp.queryLinearEquationList(params)
    console.log(res, 'res')
    drawingList.value = res.data.data.records
    drawingListTotal.value = res.data.data.total
}

// 重置
const reset = async () => {
    linearSearchForm.value.lineName = ''
    linearSearchForm.value.dateTime = [moment().add(-7, 'day').format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')]
    linearSearchForm.value.lineCategory = ''
    linearSearchForm.value.isQualified = ''
    linearSearchForm.value.pageNo = 1
    linearSearchForm.value.pageSize = 10
    getTaskMemberList()
    // templateListFn()
    templateListPresonFn()
    templateListAllFn()
    taskListFn()
    searchDrawingList()
    searchDrawingList()
}
const drawingForm = ref({
    lineCategory: 2,
    lineCategoryName: 'TN曲线',
})
const drawingTypeVisible = ref(false)
const drawingTypeList = ref([
    { label: "NH₃-N曲线", value: 1 },
    { label: "TN曲线", value: 2 },
    { label: "TP曲线", value: 3 },
])
const handleType = ref('add')
const handleRowDetail = ref({})
const drawingHandleClick = (type, row) => {
    drawingTypeVisible.value = true
}
const drawingVisible = ref(false)
const drawingType = ref(1)
const drawingTitle = ref('TN曲线')

const defaultDrawingForm = ref({
    lineCategory: '',
    lineCategoryName: '',
    instrument: '',
    temperature: '',
    humidity: '',
    method: '',
    solutionConcentUnit: '',
    wavelength: '',
    beaker: '',
    solutionConcent: '',
    blankA220: '',
    blankA275: '',
    blankAresult: '',
    backtestingblankA220: '',
    backtestingblankA275: '',
    backtestingblankAresult: '',
    points: '',
    concentrationAverage: '',
    pointsArray: [
        {
            sampleVolume: '0.50',
            multiplyValue: '',
            a275: '',
            a220: '',
            minusValue: '',
            emptyValue: '',
        }
    ],
    samplePoints: '',
    samplePointsArray: [
        {
            sampleNumber: '',
            sampleVolume: '',
            a220: '',
            a275: '',
            minusValue: '',
            emptyValue: '',
            testValue: '',
            concentrationValue: '',
            averageValue: '',
        },
        {
            sampleNumber: '',
            sampleVolume: '',
            a220: '',
            a275: '',
            minusValue: '',
            emptyValue: '',
            testValue: '',
            concentrationValue: '',
            averageValue: '',
        }
    ],
    standardConcentration: '',
    expression: '',
    intercept: '',
    rsquared: '',
    slope: '',
    isQualified: '',
})
const drawingTypeConfirm = (type, row) => {
    drawingTypeVisible.value = false
    drawingVisible.value = true
    handleType.value = 'add'
    drawingType.value = drawingForm.value.lineCategory
    drawingForm.value.lineCategoryName = drawingForm.value.lineCategory == 1 ? 'NH₃-N曲线' : drawingForm.value.lineCategory == 2 ? 'TN曲线' : 'TP曲线'
    drawingTitle.value = drawingForm.value.lineCategory == 1 ? 'NH₃-N曲线' : drawingForm.value.lineCategory == 2 ? 'TN曲线' : 'TP曲线'
    defaultDrawingForm.value.lineCategory = drawingForm.value.lineCategory
    defaultDrawingForm.value.lineCategoryName = drawingForm.value.lineCategoryName
    handleRowDetail.value = defaultDrawingForm.value
    console.log(handleRowDetail.value, 'handleRowDetail.value')
}
const curveHandleClick = (type, row) => {
    handleType.value = type
    drawingVisible.value = true
    drawingTitle.value = row.lineCategory == 1 ? 'NH₃-N曲线' : row.lineCategory == 2 ? 'TN曲线' : 'TP曲线'
    drawingType.value = row.lineCategory
    handleRowDetail.value = row
    console.log(handleRowDetail.value)
}
const delCurveHandleClick = async (row) => {
    ElMessageBox.confirm(
        `是否删除该曲线【曲线编号：${row.lineName}】？`,
        "删除",
        {
            confirmButtonText: "确认",
            cancelButtonText: "取消",
            type: "warning",
        }
    )
        .then(() => {
            taskHttp.delLinearEquation(row).then((res) => {
                if (res.data.code == 200) {
                    ElMessage({
                        message: "删除成功",
                        type: "success",
                    });
                    searchDrawingList();
                } else {
                    ElMessage({
                        message: "删除失败！",
                        type: "error",
                    });
                }
            });
        })
}
const drawingLineRef = ref(null)
const drawingConfirm = () => {
    if (drawingLineRef.value) {
        drawingLineRef.value.linearEquationConfirm()
    }
}
const linearEquationFn = async (params) => {
    console.log(params, 'linearEquationFn')
    let par = {
        depId: searchForm.value.depId,
        ...params
    }
    if (handleType.value == 'add') {
        const res = await taskHttp.addLinearEquation(par)
        console.log(res)
        if (res.data.code == 200) {
            ElMessage({
                type: 'success',
                message: '新增成功'
            })
            drawingVisible.value = false
            searchDrawingList()
        } else {

            ElMessage({
                type: 'error',
                message: '新增失败'
            })
        }
    } else {
        const res = await taskHttp.updateLinearEquation(par)
        if (res.data.code == 200) {
            ElMessage({
                type: 'success',
                message: '修改成功'
            })
            drawingVisible.value = false
            searchDrawingList()
        } else {
            ElMessage({
                type: 'error',
                message: '修改失败'
            })
        }
    }
}
const saveTemplateForm = ref({
    depId: searchForm.value.depId,
    templateName: '',
    templateType: 2,
    requiredTitlesItems: '',
    taskTemplateTimesetVos: '',
    personnelNum: 1,
    requiredIdsItems: '',
    userId: Storage.localGet('userId'),
    commets: ''
})
const saveTemplateVisible = ref(false)
const saveTemplate = () => {
    saveTemplateVisible.value = true
    let requiredTitlesItemsList = []
    let requiredIdsItemsList = []
    myTaskObj.value.taskVoList.forEach(item => {
        requiredTitlesItemsList.push(item.title)
        requiredIdsItemsList.push(item.title)
    })
    saveTemplateForm.value.commets = requiredTitlesItemsList.join(',')
}
const saveTemplateConfirm = async () => {
    let requiredTitlesItemsList = []
    let requiredIdsItemsList = []
    myTaskObj.value.taskVoList.forEach(item => {
        requiredTitlesItemsList.push(item.title)
        requiredIdsItemsList.push(item.id)
    })
    let taskTemplateTimesetVosList = []
    myTaskReportContent.value.forEach(item => {
        taskTemplateTimesetVosList.push({
            id: item.taskId,
            planStartTime: item.finishTime || '',
            planEndTime: item.finishTime || '',
            title: item.title
        })
    })
    let params = {
        ...saveTemplateForm.value,
        requiredTitlesItems: requiredTitlesItemsList.join(','),
        requiredIdsItems: requiredIdsItemsList.join(','),
        taskTemplateTimesetVos: JSON.stringify(taskTemplateTimesetVosList)
    }
    const res = await taskHttp.addTaskTemplate(params)
    if (res.data.code == 200) {
        saveTemplateVisible.value = false
        ElMessage({
            type: "success",
            message: '保存成功'
        });
    }
}
const tipsDialogVisible = ref(false)
const tipsDialog = () => {
    tipsDialogVisible.value = true
}


const relatedIndicatorActiveName = ref(0)
const taskDateChange = () => {
    getTaskMemberList()
    // templateListFn()
}
const considerationsFileUrl = ref()
const getFileInfoById = async (id, type) => {
    console.log(id, 'id')
    const { data } = await fileInfoHttp.fileInfoGetById(id)
    console.log(data, 'data.url')
    nextTick(() => {
        considerationsFileUrl.value = data.data.url
    })
}
// watch(
//     () => searchForm.value.taskDate,
//     (val) => {
//         console.log(val, 'searchForm.value')
//         getTaskMemberList()
//         templateListFn()
//     },
//     { deep: true }
// )
watch(
    () => searchForm.value.depId,
    (val) => {
        getTaskMemberList()
        // templateListFn()
        templateListPresonFn()
        templateListAllFn()
        taskListFn()
        searchDrawingList()
        searchDrawingList()
    },
    { deep: true }
)
watch(
    () => checkList.value,
    (val) => {
        if (val.length > 0) {
            templateList.list.forEach(item => {
                item[`templatechecked1`] = false
                item[`isIndeterminate1`] = false
                item[`templatechecked2`] = false
                item[`isIndeterminate2`] = false
                item[`templatechecked3`] = false
                item[`isIndeterminate3`] = false
                item[`requiredTitlesItemsList`].forEach(k => {
                    k.checked = false
                })
                item[`requiredTitlesItems2List`].forEach(k => {
                    k.checked = false
                })
                item[`requiredTitlesItems2List`].forEach(k => {
                    k.checked = false
                })
            })
        }
    },
    { deep: true }
)
onMounted(() => {
    getTaskMemberList()
    // templateListFn()
    templateListPresonFn()
    templateListAllFn()
    taskListFn()
    searchDrawingList()
})
</script>
<style lang="less">
.dialogContent {
    width: 960px;
    .dialogModel {
        .modelTitle {
            font-size: 16px;
            line-height: 18px;
            height: 18px;
            padding-left: 10px;
            border-left: 4px solid #58be3f;
            margin-bottom: 10px;
            font-weight: 500;
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            .operateIcon {
                margin-left: 10px;
                img {
                    width: 18px;
                    height: 18px;
                    margin: 0 2px;
                    cursor: pointer;
                }
            }
        }
    }
    .dialogContentTitle {
        line-height: 2.5;
        font-weight: 600;
        margin-top: 16px;
    }
    .dialogContentText {
        line-height: 2;
    }
}

.operateIcon {
    display: flex;
    flex-direction: row;
    align-items: center;
}
.taskInfo {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    padding: 26px 0 16px;
    p {
        margin-right: 60px;
        font-size: 14px;
    }
}
.templateInfo {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    .templateInfoItem {
        border: 1px solid #58be3f;
        background: #f7fcf6;
        border-radius: 8px;
        display: block;
        padding: 10px;
        width: 200px;
        margin-right: 20px;
        position: relative;
        .allChecked {
            position: absolute;
            top: 10px;
            left: 10px;
        }
        &.all {
            width: 100%;
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            flex-wrap: wrap;
            padding-top: 40px;
            p {
                margin-right: 20px;
            }
        }
        .templateInfoItemHeader {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            align-items: center;
            .itemTitle {
                line-height: 2;
            }
            .itemChecked {
                margin-right: 10px;
            }
        }
        .templateInfoItemContent {
            p {
                line-height: 2;
                display: flex;
                flex-direction: row;
                align-items: center;
                span {
                    margin-left: 5px;
                }
            }
        }
    }
}
.loactionResult {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    .loactionResultValue {
        margin-right: 10px;
    }
    .loactionResultValueItem {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        margin-bottom: 4px;
    }
}
.curveEquation {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
}

.el-col-content-mr {
    margin-right: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
}
.calculationFormula {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    margin-bottom: 12px;
    .calculationFormulaContent {
        flex: 1;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        flex-wrap: wrap;
        .calculationFormulaContentItem {
            position: relative;
            .delelteItem {
                position: absolute;
                right: 1px;
                top: -3px;
                z-index: 1000;
                background: #f56c6c;
                border-radius: 4px;
                padding: 2px 2px 0px;
            }
        }
        p {
            width: 72px;
            text-align: right;
            margin-right: 26px;
        }
    }
}
.contentStyle {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}
.success {
    color: #58be3f;
}
.danger {
    color: #f56c6c;
}
.warning {
    color: #e6a23c;
}
.nomarl {
    color: #666;
}
.demo-collapse {
    .demo-collapse-childrens_title {
        display: flex;
        flex-direction: row;
        align-items: center;
    }
}
.qualityControltitle {
    font-weight: bold;
    padding: 0px 14px 15px;
    color: #58be3f;
}
.qualityControl {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}
.dataList {
    position: absolute;
}
.tips {
    position: absolute;
    left: 360px;
    bottom: -40px;
    color: #58be3f;
    font-size: 14px;
    line-height: 40px;
    z-index: 300;
    display: flex;
    flex-direction: row;
    align-items: center;
    cursor: pointer;
}
.process {
    position: absolute;
    right: 16px;
    bottom: -40px;
    color: #58be3f;
    font-size: 14px;
    line-height: 40px;
    z-index: 300;
}
.processValuePosStyle {
    display: flex;
    flex-direction: row;
}
.my-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    cursor: pointer;
    align-items: center;
}
.rightBtn {
    display: flex;
    flex-direction: row;
    align-items: center;
}
.tempTypeTitle {
    width: 100%;
    font-weight: bold;
    margin: 15px 0px 5px;
    display: flex;
    flex-direction: row;
    align-items: center;
}
</style>